0

Tried variations of git rebase -i -Xours master but still conflicts are shown and I have to resolve them manually. Plus it's not entirely clear what happens with non conflicting changes in the case of a conflicting commit - are those kept ?

Use case: temp rebase some old branches on master to see if there are any such changes in those branches (not in master at all), but keeping the version of the code in master for conflicting changes (horrible, horrible conflicts)

$ git --version
git version 2.6.1.windows.1
Community
  • 1
  • 1
Mr_and_Mrs_D
  • 32,208
  • 39
  • 178
  • 361

1 Answers1

1
git ls-files -u | cut -f2- | uniq | git checkout-index --stdin --stage=all \
| while read base ours theirs path; do
        git merge-file --ours \
                -L "$path" -L o/"$path" -L b/"$path" \
                -- $ours $base $theirs
        mv $ours "$path"
        rm $base $theirs
done
jthill
  • 55,082
  • 5
  • 77
  • 137
  • Haha thanks - could you break this down a bit for us Bash noobs ? I guess I should run this on every single conflicting commit ? Any way to couple this with rebase ? – Mr_and_Mrs_D Jun 11 '16 at 15:09
  • 1
    Nice! The `--stage=all` option to `git checkout-index` was new to me. @Mr_and_Mrs_D: put the above into a script, run `git rebase -i`, and whenever it stops with conflicts, run the script. Automating it further requires modifying the interactive rebase shell script, I think. – torek Jun 11 '16 at 19:07