> ## Documentation Index
> Fetch the complete content index at: https://smallsharpsoftwaretools.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Jump to Git Repository Root


If you're working on a project in the CLI and you've navigated to a subfolder, you might want a quick way to navigate back to the project root. You can use a combination of `pushd` and `popd` to jump around your shell, but there's a faster way if your project is a Git repository.

## What You Need

- Git installed on your machine.

## Creating a Custom Command

The command `git rev-parse --show-toplevel` will tell you the path to the top-level directory of a repository. You can feed the result of that command to the `cd` command to jump to that folder:

```command
cd $(git rev-parse --show-toplevel)
```

That command is way too long to remember, so create an alias for it.

With the Bash shell, add an alias by adding the following line to `~/.bashrc` on Linux or `~/.bash_profile` on macOS:


```bash
alias cdr='cd $(git rev-parse --show-toplevel)'
```

If you use `zsh`, add the alias to `~/.zshrc`.

When you open a new terminal window or `source` your configuration file, you can use the command `cdr` to jump to the project root.

## Conclusion

When working in a large monorepo with subprojects, like sample code for a book or course, this is a huge time saver.

