Felix Dombek
Felix Dombek

Reputation: 14372

Ignore conflicts in file for git rebase

I am doing a very large git rebase where the only expected conflicts are changes to a version number in a txt file. Is there a way to either ignore this file during rebasing, or always use the local or remote version for this file?

Upvotes: 0

Views: 955

Answers (1)

LeGEC
LeGEC

Reputation: 51850

One way could be :

  1. first rewrite the history of your branch to remove all modifications on version.txt
  2. then rebase

You can achieve 1 using git filter-branch

Say you want to rebase branch my/branch over master:

a. Find the merge-base between my/branch and master (you will use this commit to describe the range of commits you need to rewrite with git filter-branch) :

# get the hash of :
git merge-base my/branch master

b. Discard the modifications on version.txt : one way is to always use the version which is currently on master

# in the commit range, use the 'merge-base' hash instead of eacf32 :
git filter-branch --tree-filter 'git checkout master version.txt`  eacf32..my/branch

c. Rebase :

# from branch my/branch :
git rebase master

Upvotes: 2

Related Questions