Routinely sync a branch to master using git rebase

会有一股神秘感。 提交于 2019-12-06 11:07:41
VonC

The trick is:

  • when you rebase your "template" branch, you change its history (different SHA1), meaning any push won't be a fast-forward one (there a no "new SHA1" to add, but an entirely new set of SHA1 to replace)
  • you then push that branch to a non-bare repo (which is now by default prevented)

It is a bad practice:

  • if other people depend on fetching that branch (which is not the case here)
  • if you depend on the content of the working tree of the remote repo to which you push to (because that content, if set to represent the template branch, could be not in sync with the actual template branch you just pushed)

If those two points are not an issue, you could go on.
But the (or a more) "proper" way to deal with that would be to have an intermediate bare repo (on the remote server) to push to, and then fetching/pulling the template branch from that bare repo to other server where you need that template project.

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