pwd
是「當前工作目錄」。這是情況。git pull在指定位置的本地倉庫(而不是pwd)
pwd: /path/to/pwd/
git repository: /repo/path/.git/
我想從原點做一個git pull,但不改變我的當前目錄。
爲了澄清只是更多的情況下,我不太清楚,這是我想要的結果,但我想用一個命令來做到這一點,而不必更改目錄:
$ cd /repo/path
$ git pull origin master
$ cd -
pwd
是「當前工作目錄」。這是情況。git pull在指定位置的本地倉庫(而不是pwd)
pwd: /path/to/pwd/
git repository: /repo/path/.git/
我想從原點做一個git pull,但不改變我的當前目錄。
爲了澄清只是更多的情況下,我不太清楚,這是我想要的結果,但我想用一個命令來做到這一點,而不必更改目錄:
$ cd /repo/path
$ git pull origin master
$ cd -
git --work-tree=/repo/path --git-dir=/repo/path/.git pull origin master
這很難適用。你能舉一個公共回購的例子嗎? – Cognitiaclaeves 2016-09-06 19:55:49
@Cognitiaclaeves,不確定你的意思是「難以申請」?剛剛嘗試過,它「只是工作」。它應該與你有權訪問的任何回購公開或不公開。 – 2017-03-05 20:43:29
慶典-c「cd/repo/path; git pull origin master」
這是什麼情況? (我只是好奇。) – KajMagnus 2017-04-08 05:46:31
@KajMagnus這是5年前,我真的不記得了。可能是想用單線更新repo,所以我可以根據需要使用'^ r'重複運行它,並且不會搞亂目錄堆棧,因爲我經常使用'pushd','popd'和'cd -'。 – Matthew 2017-04-13 22:43:48
可能重複[git --git-dir不按預期工作](http://stackoverflow.com/questions/1386291/git-git-dir-not-working-as-expected) – pjgranahan 2017-04-27 07:11:42