且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用git重新设置分支到另一个分支?

更新时间:2023-01-07 11:41:35

你的意思是你想推送你的本地 master 到远程修补程序分支?像这样:

  git push origin + master:hotfixes 

但是,这要求您可以在远程端重写历史记录。


let's say that we have an hotfixes branch which was created from master. we added commits to hotfixes, but those commits were not useful, so now we want to start from a fresh copy of master again.

to clarify better, this is the reference workflow: http://nvie.com/posts/a-successful-git-branching-model/

let's also say that we pushed hotfixes to the origin remote because we have an awful set up and that's the only way to test something, so we need to reset the branch also on the remote server.

how to reset hotfixes to a copy of master?

You mean you want to push your local master to the remote hotfixes branch? Like this:

git push origin +master:hotfixes

However, this requires that you are allowed to re-write the history on the remote side.