可能重複:
Is there a way to get the git root directory in one command?獲取git工作目錄根的腳本?
我寫一個bash腳本(實際上是一個Makefile文件)需要使用一個參數,相對於Git的工作目錄的根目錄包含當前目錄。
即:
/home/me$ git clone /abc/foo.git
directory foo created
/home/me$ cd foo/bar
/home/me/foo/bar$ execute_script.sh
hello /home/me/foo/baz
execute_script.sh如下:
echo hello `git something`/baz
是什麼混帳東西嗎?它應該返回當前git工作根目錄的絕對路徑。
我覺得這應該是正確的答案 – xis 2015-04-29 20:39:38