“git 推送"与“git fetch"做同样的事情从远程 [英] "git push" doing the same as "git fetch" from the remote
问题描述
我的问题与 this 相同一个,但我并不清楚答案.我有两个同步的 git repos A 和 B(对应于我工作的两台机器).当我开始在 B 工作时,我通常会执行 git fetch A
(假设 B 中的远程 A 指向 repo A).但我希望能够在我在 A 工作时从 A 推送到 B 内的远程分支 A.我想确保它是安全的,因为有关推送到非裸仓库的警告.我的设置(在文件 A/.git/config 中)是:
My question is the same as this one, but the answer is not clear to me.
I have two git repos A and B in sync (corresponding to the two machines I work on). When I start working in B, I would normally do git fetch A
(assuming the remote A in B points to repo A).
But I want instead being able to push from A to the remote branch A inside B whenever I work in A. I want to be sure that it is safe, because of the warnings concerning pushing to a non-bare repo. My settings (in file A/.git/config) would be:
[remote "B"]
fetch = +refs/heads/*:refs/remotes/B/*
push = +refs/heads/*:refs/remotes/A/*
url = ssh://<machine_B>/home/project/B
使用此设置,我是否可以通过这两个命令获得完全相同相同的结果?:
With this setting, do I get exactly the same result with this two commands? :
- 在 A 中:
git push B
- 在 B 中:
git fetch A
推荐答案
我在 kerneltrap 邮件存档,由主要的 git 开发人员之一编写.所以是的,这两个命令是等价的.
I found the exact answer to my question on kerneltrap mail archive, by one of the main git developpers. So yes, both commands are equivalent.
这篇关于“git 推送"与“git fetch"做同样的事情从远程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!