"git push"表示与"git fetch"相同从远程 [英] "git push" doing the same as "git fetch" from the remote

查看:98
本文介绍了"git push"表示与"git fetch"相同从远程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题与此问题相同一个,但答案对我来说还不清楚. 我有两个git repos A和B同步(对应于我正在使用的两台机器).当我开始在B中工作时,通常会执行git fetch A(假设B中的远程A指向仓库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
  • in A: git push B
  • in B: git fetch A

推荐答案

我在

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 push"表示与"git fetch"相同从远程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆