Check if pull needed in Git

后端 未结 24 1336
忘了有多久
忘了有多久 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 14:20

    I think the best way to do this would be:

    git diff remotes/origin/HEAD
    

    Assuming that you have the this refspec registered. You should if you have cloned the repository, otherwise (i.e., if the repo was created de novo locally, and pushed to the remote), you need to add the refspec explicitly.

提交回复
热议问题