How to see remote changes to branches in Git?
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 repo开发者_Go百科sitory. 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?
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
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
精彩评论