简体   繁体   中英

Bring Changes from Main branch to feature branch after failed merge/revert

I merged the Main branch into my feature branch, but in doing so, I ended up deleting a portion of the files that ran the feature. I reverted the changes so the feature was not lost. Now, I believe rebasing is what I wanted to do initially, though when I attempt to rebase the feature branch with the updated main branch, I am notified there are no commits to be rebased, even though some of the files in main are more up to date with the changes I want, than the feature branch. I need to bring the updated files in main over to my feature branch but I am unsure what I should do. I am working with Git.

You will perhaps have a simpler time using git cherry-pick <range of commits> :

  • in the history of your repository:

     git log --oneline --graph main feature # or use a graphical viewer

    spot the hash of the commit where feature forked from main (let's call this commit fork )

  • from your main branch, run:

     git cherry-pick fork..feature

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