"cd -" will jump back to the last directory you were at, regardless of where it is.
Add this to your .bashrc / .zshrc / whatever:
alias cdg='cd $(git rev-parse --show-cdup)'
And then type "cdg" to keep going up directories until you reach whichever folder contains your git repo. Useful when going from "/Users/philfreo/Projects/myproject/myproject/src/assets/js/views/" back up to "/Users/philfreo/Projects/myproject/"
Similarly, in zsh cd -n will take you to the nth-most-recent directory. 'dirs -v' will show the current state of the directory stack... you can do things like "dirs -v" + "cd -6" to figure out the number to use, then go to that directory.
Note that "git rev-parse --show-cdup" return the empty string if you are at the top of the git repo. So "cdg" as defined above will drop you in the hope directory if you are already at the top of your git tree.
"cd -" will jump back to the last directory you were at, regardless of where it is.
Add this to your .bashrc / .zshrc / whatever:
alias cdg='cd $(git rev-parse --show-cdup)'
And then type "cdg" to keep going up directories until you reach whichever folder contains your git repo. Useful when going from "/Users/philfreo/Projects/myproject/myproject/src/assets/js/views/" back up to "/Users/philfreo/Projects/myproject/"