Salahuddin
Salahuddin

Reputation: 1719

How to check what git rebase had changed?

Is there a way to check what git rebase had changed after doing the rebase and exiting rebase mode?

I used rebase to change the author name of previous commits.

While trying to do so, I rebased in wrong branch (i.e., master) which viewed to me in the rebase file some commits that were not my target. Therefore, I just quit the editor and it said "Rebase done successfully".

At the end, I switched to my local branch (i.e., vIO) and I could change the author name but I want to check that my other rebasing trials didn't affect the history. BTW, my local branch (vIO) is not yet pushed to remote.

I tried comparing local master to remote master by:

git diff origin/master...master

This didn't bring anything. Does this mean for sure that the master branch was not affected by the rebasing?

Upvotes: 4

Views: 5679

Answers (1)

LeGEC
LeGEC

Reputation: 51850

git keeps a log for each separate branch, which you can access through the git reflog command :

  • git reflog master will show you the evolution of your local master branch,
  • git reflog vIO the evolution of your local vIO branch.

In this reflog, actions that were applied by a rebase will appear with a message :

rebase (finish): refs/heads/branchname onto eacf32bb...

The git diff origin/master...master command told you that there was no new content on master, which is a good indication.

If you want to be 100% sure master didn't move, look at the list of commits with git log :

git log --graph --oneline origin/master master

will allow you to see if there are any different commits the two branches :

  • if the labels master and origin/master appear on the same commit, the two branches are in sync ;
  • otherwise, look at the graph to understand what action should be taken (pull, push, merge, rebase ...)

Upvotes: 4

Related Questions