8

There must be something I've overlooked when I learned Git. After all I'm fairly new to it.

My workmate says he's pushed back some changes he made to my commit in our remote repository. However the git log has no record of this new push.

How can I see what he pushed and thus know what branch to pull?

Richard Ev
  • 52,939
  • 59
  • 191
  • 278
why
  • 195
  • 3
  • 12

2 Answers2

8

you have to git fetch his changes first. you can then show them using git log origin/branch (branch being very likely master)

git fetch retrieves all the remote changes, copies them to your local clone and updates the remote-tracking branches (those origin/… stuff, see git branch -a). to get his changes into your local branch, use either git pull or git merge

knittl
  • 246,190
  • 53
  • 318
  • 364
  • 1
    Alternatively to git log, you can also use the graphical tool gitk (for which you'll want to show all branches: gitk --all), or in console mode: git show-branch -a – François Mar 16 '11 at 08:31
5

When you have the origin fetched like mentioned, you can always

git status

which will mention your current branch and whether you are ahead/behind the tracking branch (man git branch)

git log --left-right --graph --cherry-pick --oneline HEAD...origin/master

is my very very preferred alias for things. I have even created an alias for this (lr from left-right) and extended bash_completion for the purpose.

Consider adding a remote for the origin (if you clone from the origin, you'll have one automatically). You can then 'git remote update' to get all latest refs from the remote

sehe
  • 374,641
  • 47
  • 450
  • 633