10

How I can get current working dir from console using git?

something like: if I'm in: ~/projects/someproject/somesubfolder/, the console command should say /home/va1en0k/someproject/ (if there is a .git/ folder in this directory or something like this)

or if GIT_WORKING_DIR is set, it should return it. or whatever Git uses to determine it

valya
  • 938

2 Answers2

22

Simple: git rev-parse --show-toplevel

sorin
  • 12,189
12

Try this:

echo $( cd $(git rev-parse --show-cdup); pwd)