我怎样才能生成自上次拖拉后发生变化的git diff? [英] How can I generate a git diff of what's changed since the last time I pulled?

查看:138
本文介绍了我怎样才能生成自上次拖拉后发生变化的git diff?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想脚本,最好在rake中,将以下操作合并到一个命令中:

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


  1. 获取我的本地版本git存储库。

  2. Git获取最新的代码。

  3. 从步骤#1中提取的版本中的Git diff到现在在本地存储库中的内容。
  1. Get the version of my local git repository.
  2. Git pull the latest code.
  3. Git diff from the version I extracted in step #1 to what is now in my local repository.

换句话说,我想从中央存储库获取最新代码,并立即生成自上次更改以来的差异我可以很简单地用refspecs来做这件事。

In other words, I want to get the latest code form the central repository and immediately generate a diff of what's changed since the last time I pulled.

推荐答案

git pull origin
git diff @{1}..

这会给你一个当前分支的差异,因为它存在于拉之前和之后。请注意,如果拉不实际更新当前分支,diff会给你错误的结果。另一个选择是显式记录当前版本:

That will give you a diff of the current branch as it existed before and after the pull. Note that if the pull doesn't actually update the current branch, the diff will give you the wrong results. Another option is to explicitly record the current version:

current=`git rev-parse HEAD`
git pull origin
git diff $current..

我个人使用一个别名, ,按照相反的顺序(即从最旧到最新),无合并,自从我上次拉取以来的所有提交。每次我的pull更新分支时,我都会运行它:

I personally use an alias that simply shows me a log, in reverse order (i.e. oldest to newest), sans merges, of all the commits since my last pull. I run this every time my pull updates the branch:

git config --global alias.lcrev 'log --reverse --no-merges --stat @{1}..

这篇关于我怎样才能生成自上次拖拉后发生变化的git diff?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆