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

后端 未结 4 667
失恋的感觉
失恋的感觉 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:40

    Greg's way should work (not me, other Greg :P). Regarding your comment, origin is a configuration variable that is set by Git when you clone the central repository to your local machine. Essentially, a Git repository remembers where it came from. You can, however, set these variables manually if you need to using git-config.

    git config remote.origin.url 
    

    where url is the remote path to your central repository.

    Here is an example batch file that should work (I haven't tested it).

    @ECHO off
    
    :: Retrieve the changes, but don't merge them.
    git fetch
    
    :: Look at the new changes
    git diff ...origin
    
    :: Ask if you want to merge the new changes into HEAD
    set /p PULL=Do you wish to pull the changes? (Y/N)
    IF /I %PULL%==Y git pull
    

提交回复
热议问题