0

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?

Felix Dombek
  • 11,461
  • 15
  • 67
  • 116
  • [This](https://stackoverflow.com/questions/10697463/resolve-git-merge-conflicts-in-favor-of-their-changes-during-a-pull) should answer your question, I suppose – Alexey Larionov May 18 '20 at 12:00

1 Answers1

2

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
LeGEC
  • 29,595
  • 2
  • 37
  • 78