Git push Refspecs: `refs/heads/*:refs/heads/origin` vs `refs/heads/*:refs/heads/*`

我的梦境 提交于 2019-12-24 10:51:53

问题


Which push Refspec (Git) is correct? Or both are correct? What is the difference?

  1. refs/heads/*:refs/heads/origin/*
  2. refs/heads/*:refs/heads/*

I prefer (1) because it references remote name (origin), and I don't understand what (2) means (but I see it used in some manuals!).


回答1:


With refs/heads/*:refs/heads/origin/*, git push origin master would be expanded to git push origin refs/heads/master:refs/heads/origin/master. It will create or update a branch named origin/master in the remote repository. It's valid, but refs/heads/origin/master would be ambiguous with refs/remotes/origin/master. In some situations, it might cause errors.

The 2nd is valid. With remote.origin.push=refs/heads/*:refs/heads/*, git push is expanded to git push origin refs/heads/master:refs/heads/master refs/heads/dev:refs/heads/dev, and git push origin master to git push origin refs/heads/master:refs/heads/master.



来源:https://stackoverflow.com/questions/56562293/git-push-refspecs-refs-heads-refs-heads-origin-vs-refs-heads-refs-heads

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!