l can use
git status
git pull
git push
git add .
git commit -m "xxx"
git push
! [rejected] master -> master (fetch first)
error: failed to push some refs to
'git@code.xxx.com/xxxx'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
The usual way to answer this question locally is to do a git fetch
. This will update the local tracking branch origin/master
, which is what Git uses locally to figure out whether your local master
branch is ahead or behind of the true remote master
branch. So all you need to do here is the following:
git fetch origin
git status
You might see output looking something like the following:
This branch is 2 commits ahead and 2 commits behind master
If this were your status, it would imply that you had made two commits since the point when you last synched. And it would also mean that other people had laid down two commits to the remote master
branch since the last sync.