How can I generate a git diff of what's changed since the last time I pulled?

后端 未结 4 670
失恋的感觉
失恋的感觉 2020-12-07 08:24

I\'d like to script, preferably in rake, the following actions into a single command:

  1. Get the version of my local git repository.
  2. Git pull the latest
4条回答
  •  盖世英雄少女心
    2020-12-07 08:25

    If you drop this into your bash profile you'll be able to run grin (git remote incoming) and grout (git remote outgoing) to see diffs of commits that are incoming and outgoing for origin master.

    function parse_git_branch {
      git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
    }
    function gd2 { 
     echo branch \($1\) has these commits and \($2\) does not 
     git log $2..$1 --no-merges --format='%h | Author:%an | Date:%ad | %s' --date=local
    }
    function grin {
     git fetch origin master
     gd2 FETCH_HEAD $(parse_git_branch)
    }
    function grout {
     git fetch origin master
     gd2 $(parse_git_branch) FETCH_HEAD
    }
    

提交回复
热议问题