0

I have two branches feature and master. I haven't worked on the feature branch in several months and the directory structure of the master branch has changed quite a bit.

I am trying to merge the master branch into my feature branch. Since there are many conflicts, renames and modifications that have occurred I am trying to incrementally perform the merge.

Is there a way I can kick off this process by just merging the renamed files (with 100% match) to begin with?

Ideally something like

git merge --diff-filter=R -M100% master

Since merge has no --diff-filter=R or -M commands I'm wondering if there is another way to do this?

Ddor
  • 347
  • 1
  • 12
  • I thought git tracks renamed files correctly. – mfnx Sep 04 '19 at 12:35
  • You can try getting a diff that lists the renamed files. Then apply those first on the branch, before proceeding with the merge. – Gino Mempin Sep 04 '19 at 13:45
  • 2
    With Git, you cannot do an "incremetal merge" with `git merge`. It is all or nothing. If you want to do it incrementally, rebase your feature branch incrementally, i.e., you rebase it to `master~100`, then `master~50`, finally to `master`. Ideally, you choose strategic commits; for example, `big-rename~1`, then `big-rename`, where `big-rename` is a commit that does a lot of renaming. – j6t Sep 04 '19 at 13:56

1 Answers1

0

I'm not sure why you would want to start with only the renamed files, but if that is your plan, then approach that comes to mind is:

1) From your feature branch, run:

git merge master

Git will force you to fix merge conflicts before you can complete the merge.

2) Run git status which will show all modified and staged files in your working directory, from this you can see which have been renamed.

2) Stage any files which are list as renamed. For each relevant file:

git add <file>

3) Undo any changes to non-renamed files to what they were before the merge. For each relevant file:

git checkout -- <file>

3) Commit the renamed files:

git commit

Will Taylor
  • 1,650
  • 9
  • 23