Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git alias get cwd

Tags:

git

If I define a git alias that executes an external script is there any way to get the original CWD? I know external scripts always execute at the root of the repo so I was just wondering if there was an env variable or something I could use to figure out where I ran my script.

Here is an example alias:

git config --global alias.here '!echo pwd `pwd`'

/home/me/repo/folder$ git here
pwd /home/me/repo

I'm looking for something that does the following:

git config --global alias.here '!echo pwd $OLD_PWD'


/home/me/repo/folder$ git here
pwd /home/me/repo/folder
like image 341
HaxElit Avatar asked Jan 27 '12 20:01

HaxElit


1 Answers

As per the manual, you should be able to use GIT_PREFIX, which will be set with the same prefix as returned by git rev-parse --show-prefix. You can append that prefix to the root path.

http://schacon.github.com/git/git-config.html

like image 98
manojlds Avatar answered Nov 04 '22 13:11

manojlds