Skip to content

Instantly share code, notes, and snippets.

@natersoz
Last active May 5, 2020 17:50
Show Gist options
  • Save natersoz/ad529d8963bd0a95ce902adc275843f4 to your computer and use it in GitHub Desktop.
Save natersoz/ad529d8963bd0a95ce902adc275843f4 to your computer and use it in GitHub Desktop.
git rebasing and comparisons

Differencing a branch after a Rebase

Let’s say you have a branch. The copy on the server 'origin is up to date with your local branch.
You rebase to master: 

    git rebase master
        
(of course it would be best to do so if your local master is up to date with origin master)
Now, you want to know what changed - only for the working set of files in your branch - when you did the rebase. 
You can do this:

    git diff --stat origin/<branch_name> -- `git diff --name-only master`

What this says is “For all the files I changed with respect to master tell me which ones have changed after I did the rebase”.
And then if you have git difftool set up you can change that command to be:

    git difftool -y origin/<branch_name> -- `git diff --name-only master`
   
And that will use your differencing tool to show the diffs in each of those files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment