How to know if git repository has changes that have not been synchronized with server (origin)?

前端 未结 4 2022
暗喜
暗喜 2021-01-02 01:55

I have a large number of projects setup in Git that were previously managed in CVS. Tortoise CVS as well as Eclipse both made it very easy to see (via icon overlays) if I ha

4条回答
  •  离开以前
    2021-01-02 02:29

    Yesterday I tried to roll my own solution. Here's what I came up with (for a single repository):

    #!/bin/sh
    
    for ref in $(git for-each-ref --format='%(refname)' refs/remotes/); do
        ending=${ref#refs/remotes/}
        remote=${ending%/*}
        branch=${ending#*/}
        if [ "${branch}" == "HEAD" ]; then continue; fi
        echo -e "\e[1;34m$branch on $remote\e[0m"
        echo "AHEAD by:"
        git log --oneline $branch ^$remote/$branch
        echo "BEHIND by:"
        git log --oneline $remote/$branch ^$branch
    done
    

    This was based off info I've pulled several sources including answers here. I'm still a bit shady on what the 'git log' command is doing given the parameters I'm providing -- but it seems to spit out the kind of info I want.

提交回复
热议问题