Git read updates before pulling

40 Views Asked by At

Whenever I have a Git error on pulling, where "Updates were rejected because the tip of your current branch is behind" is there any way to know what are the updates that have been done on the origin repository after doing git fetch ?

2

There are 2 best solutions below

0
On

After a git fetch of your origin repository, you would be able to run commands such as:

git log origin...HEAD 

This will show the git log of changes between your current HEAD and origin's HEAD. Be sure to pass in your favorite git log arguments here, I like --stat myself.

You can do something similar with the diff command:

git diff origin/master # or whatever your current branch is

This will show you the actual file changes on the remote.

1
On

git rev-list HEAD..HEAD@{upstream}

after a git fetch returns a list of the new remote commits in reverse chronological order.