简体   繁体   中英

GIT reset branch and delete all changes after merge

I had two branches, the main one and a feature branch. After changing something in the main branch (I know now, that's bad practice. I found out the best practice for changes and I'll do it by the book next time) I merged the main branch into the feature branch.

The merge went bad, so I reset the branch back to the last commit before the merge. This went well. Only problem is, if I want to commit any new changes, the merge gets included again.

I tried rebasing the branch, I wasn't successful.

I just want to completely delete the merge and get back to the last commit, Is that possible?

Hope is by now you've figured out you shouldn't develop directly on the main branch. You should take the following steps:

  1. Reset your main branch to before the merge
  2. Rebase your feature branch on top of main branch
  3. Make your changes in the feature branch, commit and what not
  4. Go to main branch and merge feature branch into it

如果由于冲突而不想合并它,请尝试使用git merge --abort命令。

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