Compare git branch with reinstalled branch

I replaced the fairly old topic thread with master. Since there were quite a lot of conflicts during rebase, I would like to compare the thread of the old topic with the re-thread, to make sure that I did not accidentally delete or make any changes to the topic. The closest I came to is distinguished by the results of git diff master...topic and git diff master...topic-rebased . This kind of work, but there is a lot of noise in the last difference from changing context code, line numbers, commit hashes, etc., In addition to this, this is not a very reliable solution. Is there an easier way to do this?

+6
source share
3 answers

You will probably want to separate the effective changes (patches) created by each of them:

 diff <(git log master..topic -p) <(git log master..old-place-of-topic -p) 

This will effectively eliminate any changes made to the wizard.

+4
source

I struggled with the same problem and came up with similar ideas, such as Ryan and Adam Dymtruk, and found them not very satisfactory: comparing the final analysis is difficult and also does not show you where the β€œerror” was introduced if you find it.

In my current rebuild workflow, there is a comparison of each reinstalled commit with the original, so I can identify and fix potential errors as they occur and not restart again. I use the following pair of git aliases to facilitate this:

 rc = !git diff -w $(cat .git/rebase-merge/stopped-sha) > .git/rebase-merge/current-diff rd = !git diff -w $(cat .git/rebase-merge/stopped-sha) | diff --suppress-common-lines .git/rebase-merge/current-diff - | cut -b 1-2 --complement | less 

git rc stores the difference between the latest HEAD version from a branch that is reinstalling. After replaying the next commit, git rd compares this saved diff with the difference between the new HEAD and the next commit on the branch allocation. Therefore, it shows that only the difference (β€œerror”) is introduced by replaying the last commit.

After checking diff, call git rc to update the saved diff and continue rebase.

Instead of manually calling git rc and git rd you can even add them to your git-rebase-todo so that they are called automatically after replaying each commit.

+4
source

If you don't care about the commit history from your topic thread, you can redo the rebase and add the -squash flag. This will give you one commit on top of the main branch, where you can also go through the file of modified files by file. I would also add the --no-commit flag for redirection, so that I can see the changes before intercepting git.

 git checkout master git rebase --squash --no-commit topic //review changes with your favourite git tool git commit 

If you don't want to redo rebase, external tools like KDiff3 can help you.

0
source

Source: https://habr.com/ru/post/908564/


All Articles