Check if pull needed in Git

后端 未结 24 1552
忘了有多久
忘了有多久 2020-11-22 13:34

How do I check whether the remote repository has changed and I need to pull?

Now I use this simple script:

git pull --dry-run | grep -q -v \'Already          


        
24条回答
  •  时光取名叫无心
    2020-11-22 13:59

    The command

    git ls-remote origin -h refs/heads/master
    

    will list the current head on the remote -- you can compare it to a previous value or see if you have the SHA in your local repo.

提交回复
热议问题