简体   繁体   中英

I accidently branched off of a branch, now I want to undo this

How do I fix a branch so that it is synced with master? It'd almost be easier to delete the branch and then remake it, but I was wondering if there was a way to do this without it coming to that?

When I made the branch, I branched off another branch instead of master.

Rebase your changes onto master:

git rebase --onto master your-previous-source-branch

(when your current branch is active)

This will rewrite your branch like it was just branched off master and have all commits to it done after it.

Note that it will not be the same branch anymore and you'll have to do a forced push to remote, if branch is already there, be sure not to overwrite someone other's commits to it

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM