1

I'm trying to rebase my feature branch with the master branch, but while rebasing, the master branch is overwriting the changed files and throwing merge conflicts and asking me to resolve them. But since I have changed soo many files, its hard to resolve the merge conflicts. Is there a way to rebase with master soo that my changes files are kind of forced onto the existing files in master?

Aiguo
  • 3,416
  • 7
  • 27
  • 52
  • 2
    Possible duplicate of [How do I select a merge strategy for a git rebase?](http://stackoverflow.com/questions/2945344/how-do-i-select-a-merge-strategy-for-a-git-rebase) – Whymarrh Nov 01 '16 at 22:43
  • If you get a merge conflict it means the file(s) was changed in both branches - in your dev branch and in master. You should resolve conflicts or someone's changes will be lost. Is it acceptable? – Ivan Nov 02 '16 at 05:40
  • Yes @Ivan, that is totally acceptable. But, my goal is to overwrite only few specific files and not everything thats on my feature branch. So basically I want to cherry-pick files from my branch and force them to the master branch. – Aiguo Nov 02 '16 at 12:07

1 Answers1

1

If you get merge conflicts, you have to resolve them. Though it is possible, you typically do not want to force your changes over someone else's changes (regardless of which version control system you are using), since other developers' work would be lost.

It sounds as if you have simply diverged too much from your upstream, either because you have not synced/rebased locally often enough, or you have refactored/touched lots of code so that conflicts are more or less inevitable.

A work-flow that works fairly well in a team is to sync and rebase often during the development of your feature branch. E.g, it your central remote is origin and your upstream branch is master, do the following once in a while:

git fetch origin
git rebase origin/master

In addition, you can save yourself some trouble by being conscious about what changes you make (e.g. don't change unnecessary things, such as code formatting, variable/function names etc. of code that is not vital to you patch).

Fixing it as an after-thought can be a real pain, and sometimes it's simpler to redo the work in a new branch based on a fresh master (possibly using git cherry-pick to get the most important work from your old branch).

m-bitsnbites
  • 994
  • 7
  • 19