4

拉取之后,git 会列出自上次拉取以来修改的文件。

问题是,如何在本地 repo 上完成更多工作后获取此列表。

例如

$ git checkout feature/default2
$ git pull
Updating 5420c70..b8eec49
Fast-forward
 application/configs/application.ini                                 |   1 +
 application/modules/product/forms/Search.php                        |   3 ++
 public/themes/default/bootstrap/buttons.less                        |  25 -----------
 public/themes/default/css/cmspanel.css                              | 234 ++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------
 public/themes/default/css/products.css                              |  57 ++++++++++++++++++++----
 public/themes/default/css/style.css                                 | 270 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------
 public/themes/default/gfx/icons/menu-drop-dark.png                  | Bin 0 -> 160 bytes
 public/themes/default/gfx/icons/more.png                            | Bin 0 -> 120 bytes
 public/themes/default/layouts/scripts/footer.phtml                  |  26 ++++++++++-
 public/themes/default/layouts/scripts/gallery.phtml                 |   2 +
 public/themes/default/layouts/scripts/home.phtml                    |   2 +
 public/themes/default/layouts/scripts/layout.phtml                  |   2 +
 public/themes/default/layouts/scripts/products.phtml                |  22 ++++-----
 public/themes/default/less/cmspanel.less                            |  26 +++++++++++
 public/themes/default/less/nav.less                                 |   4 +-
 public/themes/default/less/products.less                            |  61 +++++++++++++++++++++----
 public/themes/default/less/style.less                               |  59 ++++++++++++++++++++++---
 public/themes/default/less/widgets.less                             |  37 +++++++++++++++-
 public/themes/default/modules/cms/scripts/widgets/random.phtml      |   6 +--
 public/themes/default/modules/default/scripts/widgets/submenu.phtml |   2 +-
 public/themes/default/modules/product/scripts/index/view.phtml      |  44 +++++++++---------
 public/themes/default/modules/product/scripts/widgets/search.phtml  |  16 +++++++
 22 files changed, 584 insertions(+), 315 deletions(-)
 create mode 100644 public/themes/default/gfx/icons/menu-drop-dark.png
 create mode 100644 public/themes/default/gfx/icons/more.png

5420c70是拉之前的状态。
怎么确定那个5420c70sha?

如果我是正确的,ORIG_HEAD 是最后一次拉动之前的状态(任何拉动,而不是引入一些变化的拉动)。

我正在寻找一些喜欢为我git checkout SOME_HEAD做的魔法别名git checkout 5420c70

我正在尝试设置一个git review别名,它应该区分自上次拉取以来修改的所有文件,这不是最新的。

在基本情况下,类似这样的工作:

git pull
# lists some chanes file
git diff --name-status ORIG_HEAD..
# diffs them

但我正在寻找这样的东西:

git pull
# lists some chanes file
git pull
# up-to-date, no changes
git diff --name-status ORIG_HEAD..
# diffs the files since the last pull which was not up-to-date
4

4 回答 4

4

我认为您可以检查 reflog,即HEAD@{1},例如 it diff --name-only ..HEAD@{1}

作为另一种选择,您可以查看即将发生的更改,然后git fetch将更改带入您的工作副本。git log -p ..@{upstream}git merge FETCH_HEAD

于 2013-07-08T09:53:02.797 回答
3

在查看 reflog 之后,我发现这就是我想要的:

git reflog --oneline | grep -m 1 "pull " | cut -d' ' -f1)

这将只返回先前成功拉取的一个 sha,可用于show,logdiff

于 2013-07-08T10:49:08.123 回答
0

如果我明白你想要什么,git pull不是你需要的命令,你应该看看git fetch

完成后你可以做

git diff HEAD...origin 请注意,您需要 3 个点而不是通常的 2 个

这将给出所有更改的单一差异。当您满意时,您可以以通常的方式将它们与git merge或使用git cherry-pick仅选择某些

于 2013-07-08T10:07:00.730 回答
0
git log -n 1 --pretty=format:%H
于 2016-07-13T08:20:00.873 回答