Git [origin/main: ahead 1, behind 2]


You may encounter the following message when using git:

User01@Lab website % git branch -avv
  dev                        e2b3fd5 add cs
  main                       69e4313 [origin/main: ahead 1, behind 2] add cs
  remotes/origin/HEAD        -> origin/main
  remotes/origin/dev         3fb9062 Update xxx
  remotes/origin/main        9e0dbc2 Updates xxx Merge branch 'dev'

The notation [origin/main: ahead 1, behind 2] indicates:

ahead 1”: One local commit has not been pushed to the remote branch(origin/main).

behind 2”: Two commits on the remote branch(main) have not been pulled to the local branch.


To synchronize your branches, you can follow these steps:

# Merge the remote changes into your local branch
git merge

# If any merge conflicts occur, resolve them and then commit:
git commit -am "some comments"
# If there are no conflicts, you can skip the above commit


# Push the merged state to the remote repository
git push