git: diff between file in local repo and origin

后端 未结 7 2156
我在风中等你
我在风中等你 2020-12-04 04:42

I want to find the differences between a file I have in my local repo vs what is in the origin master.

I know that there is git diff, howev

7条回答
  •  余生分开走
    2020-12-04 05:24

    I tried a couple of solution but I thing easy way like this (you are in the local folder):

    #!/bin/bash
    git fetch
    
    var_local=`cat .git/refs/heads/master`
    var_remote=`git log origin/master -1 | head -n1 | cut -d" " -f2`
    
    if [ "$var_remote" = "$var_local" ]; then
        echo "Strings are equal." #1
    else
        echo "Strings are not equal." #0 if you want
    fi
    

    Then you did compare local git and remote git last commit number....

提交回复
热议问题