Git - push to a remote-tracking branch in the remote repository

别来无恙 提交于 2019-12-23 10:27:26

问题


When simply doing git push to a remote repository, its master branch gets updated. This is undesirable in the case of non-bare repositories, and the warning message displayed by recent Git versions makes that clear.

I'd like to be able to push to a remote repository, and have one of its remote tracking branches be updated. Later, when I log in to the remote machine and run commands, I can choose to merge that remote tracking branch into master.

How can I do that? Or is there a better way to push changes to a non-bare repository?


回答1:


You can do:

git push master:some-remote-branch

for example:

git push master:alex/master

(Although it is still not recommended to push to non-bare repository.)




回答2:


I guess you should just set up a separate bare repository, ie. one without a working copy. Then you could just log in to the remote machine and clone this remote repository, and fetch/pull whenever you need it.



来源:https://stackoverflow.com/questions/2144866/git-push-to-a-remote-tracking-branch-in-the-remote-repository

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