gpt4 book ai didi

git - 为 git pull 指定目录(不是当前目录)

转载 作者:太空狗 更新时间:2023-10-29 13:20:04 26 4
gpt4 key购买 nike

我想从 git 更新我现有的 checkout ,但不在该目录中:

-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-dirwork-tree,谁能解释一下我做错了什么?

最佳答案

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)

关于git - 为 git pull 指定目录(不是当前目录),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30924756/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com