我想从git更新我现有的结帐,但不在该目录内:
-sh-3.2$ pwd
/var/lib/gitolite
-sh-3.2$ git clone repositories/visits.git/
Cloning into 'visits'...
done.
-sh-3.2$ cd visits/
-sh-3.2$ git remote -v
origin /var/lib/gitolite/repositories/visits.git/ (fetch)
origin /var/lib/gitolite/repositories/visits.git/ (push)
-sh-3.2$ cd
-sh-3.2$ git --git-dir=/var/lib/gitolite/repositories/visits.git/ --work-tree=/var/lib/gitolite/visits/ pull
fatal: No remote repository specified. Please, specify either a URL or a
remote name from which new revisions should be fetched.
-sh-3.2$ cd visits/
-sh-3.2$ git pull
Already up-to-date.
-sh-3.2$ git --version
git version 1.8.2.1
-sh-3.2$
我真的不明白git-dir
和work-tree
,有人可以解释我做错了什么吗?
答案 0 :(得分:7)
git-dir
应指向本地副本的.git
文件夹(您的文件指向您克隆的远程存储库):
示例:
~/tmp> git clone repositories/my-project.git/
Cloning into 'my-project'...
done.
~/tmp> git --git-dir=/Users/jhoffmann/tmp/my-project/.git \
> --work-tree=/Users/jhoffmann/tmp/my-project/ pull
Already up-to-date.
Git version 1.8.5介绍-C
,将其简化为:
~/tmp> git -C /Users/jhoffmann/tmp/my-project/ pull
Already up-to-date.
(摘自this answer)