3

When I execute: git pull --rebase from my feature branch, I get conflicts in lot of files which I've never edited. To get rid of these conflicts I execute following set of commands for each and every conflicted files.

git checkout --ours .

git add .

git rebase --continue

The annoying part is I have to execute this for every conflicts. Is there any way to configure git with a custom command so that above all commands will execute at once.

Something like:

If(featureBranch_04) {
   foreach(conflicts)
      if(conflictedFile != index.jsp) {
          git checkout --ours .
          git add .
          git rebase --continue
      }
   }
}

Can I have a similar function in git config ?

The workflow is: First I merged the master branch into featureBranch_04, and then git pull --rebase from the featureBranch_04 branch.

Ashish Gaur
  • 2,030
  • 2
  • 18
  • 32
giri_col
  • 95
  • 8
  • 2
    Why are you doing `git pull --rebase` in the first place? Why not just `git pull` and then rebase your branch afterwards? – Ja͢ck Oct 30 '13 at 07:03

1 Answers1

2

You could try a:

git fetch
git rebase -s recursive -X theirs origin/featureBranch_04

That would pass the merge strategy 'theirs' to the merge part of a rebase.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Given that rebase reverses the "ours/theirs" sense, wouldn't "-s theirs" be right? Or does rebase change user-supplied arguments to match the sense-swap? – torek Oct 30 '13 at 12:56
  • @torek thank you. Fixed. I should have known, I have written extensively about this: http://stackoverflow.com/a/3052118/6309 – VonC Oct 30 '13 at 13:00