Git push only for bare repositories?

限于喜欢 提交于 2019-11-26 20:36:37

Read the warning carefully. The new default prohibition is only on pushing to the currently checked out branch in a non-bare repository. It is perfectly OK to push to any other branch in a non-bare repository.

The reason for this is that the push process has no direct access to the working tree so the index and branch head get changed under the working tree. When you subsequently go to the working tree it looks like working tree has undone the changes pushed mixed in with any changes that were genuinely in development. This makes it very difficult to separate the two sets of changes.

Pushing to other branches has no such downsides. You can then go to that repository and merge those changes into the checked out branch if desired.

You shouldn't push to a non-bare repository because pushing will only update the internal state of the repo, and won't affect the checked-out, on-disk copies of the files. Thus, you could run into problems if you start doing work in that repo without first updating (via git checkout) the on-disk copies of the state of the files in the repo.

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