Check if pull needed in Git

后端 未结 24 1333
忘了有多久
忘了有多久 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:06

    Here's my version of a Bash script that checks all repositories in a predefined folder:

    https://gist.github.com/henryiii/5841984

    It can differentiate between common situations, like pull needed and push needed, and it is multithreaded, so the fetch happens all at once. It has several commands, like pull and status.

    Put a symlink (or the script) in a folder in your path, then it works as git all status (, etc.). It only supports origin/master, but it can be edited or combined with another method.

提交回复
热议问题