GIT - Rebase - How to deal with conflicts

后端 未结 5 812
长发绾君心
长发绾君心 2021-02-09 02:07

I am working on a project that has two branches: master and feature

The feature branch was created some time ago and has numerous

5条回答
  •  再見小時候
    2021-02-09 02:45

    I do not care about the history of the commits.

    If you really don't care about history, a git merge --squash is going to let you resolve all your conflicts at once and produce a single commit with all the changes.

    To essentially do that --squash in-place, you could do something like this:

    git branch -m feature feature-old
    git checkout master -b feature
    git merge --squash feature-old
    

    After you resolve all conflicts (once), you will create a single commit on feature that has master as a parent.

    That being said, I'm a fan of keeping history. Definitely try rerere first. You might also try an in-place rebase --interactive (e.g. git rebase -i $(git merge-base HEAD master)) to squash the fixup-type commits without completely eliminating all the discrete commits.

提交回复
热议问题