Git: How to check if a local repo is up to date?

2019-01-30 23:43发布

I would like to know if my local repo is up to date (and if not, ideally, I would like to see the changes).

How could I check this without doing git fetch or git pull ?

9条回答
地球回转人心会变
2楼-- · 2019-01-31 00:36

You'll need to issue two commands:

  1. git fetch origin
  2. git status
查看更多
迷人小祖宗
3楼-- · 2019-01-31 00:36

Another alternative is to view the status of the remote branch using git show-branch remote/branch to use it as a comparison you could see git show-branch *branch to see the branch in all remotes as well as your repository! check out this answer for more https://stackoverflow.com/a/3278427/2711378

查看更多
萌系小妹纸
4楼-- · 2019-01-31 00:37

You must run git fetch before you can compare your local repository against the files on your remote server.

This command only updates your remote tracking branches and will not affect your worktree until you call git merge or git pull.

To see the difference between your local branch and your remote tracking branch once you've fetched you can use git diff or git cherry as explained here.

查看更多
登录 后发表回答