How to check for changes on remote (origin) Git repository

后端 未结 8 1760
伪装坚强ぢ
伪装坚强ぢ 2020-12-04 04:12

What are the Git commands to do the following workflow?

Scenario

I cloned from a repository and did some commits of my own to my local reposit

相关标签:
8条回答
  • 2020-12-04 05:15
    git remote update && git status 
    

    Found this on the answer to Check if pull needed in Git

    git remote update to bring your remote refs up to date. Then you can do one of several things, such as:

    1. git status -uno will tell you whether the branch you are tracking is ahead, behind or has diverged. If it says nothing, the local and remote are the same.

    2. git show-branch *master will show you the commits in all of the branches whose names end in master (eg master and origin/master).

    If you use -v with git remote update you can see which branches got updated, so you don't really need any further commands.

    0 讨论(0)
  • 2020-12-04 05:16

    git status does not always show the difference between master and origin/master even after a fetch.

    If you want the combination git fetch origin && git status to work, you need to specify the tracking information between the local branch and origin:

    # git branch --set-upstream-to=origin/<branch> <branch>
    

    For the master branch:

    git branch --set-upstream-to=origin/master master
    
    0 讨论(0)
提交回复
热议问题