If I have one change:
Force git to treat "a change" and "an addition" separately?:

- 103
- 1
- 12
-
So you would like to see those lines (on the left) as first removed and then the lines on the right added on two separate revisions? – eftshift0 Apr 23 '19 at 13:26
-
I thought https://stackoverflow.com/questions/4460202/how-to-set-patience-as-default-git-diff-algorithm would help but it didn't – Rules Apr 23 '19 at 14:23
-
I already provided a detailed recipe – eftshift0 Apr 23 '19 at 14:37
-
Thanks I'll try to repeat that some time later It's not that easy... – Rules Apr 23 '19 at 15:56
1 Answers
First, commit the change in full (all changes at the same time, the way you want it to look like after the two revisions) and place a temporary branch there... like 'blah' git branch blah
(no need to check it out).
Then set the file the way you want it on the first revision and amend the revision (git commit --amend -m "first change, blah blah"
).
Checkout blah (git checkout blah
) and set the branch pointer on the other branch you were working on originally (git reset --soft the-other-branch
, that won't touch the other branch, no worries). At this point the changes for the second revision are on the index.
Commit (git commit -m "second change for the file, blah blah"
). Now blah has the changes one after the other the way you wanted originally. If you like the result of the history of the branch, force the other branch to where blah is and remove branch: (git branch -f the-other-branch; git checkout the-other-branch; git branch -d blah
).

- 26,375
- 3
- 36
- 60