问题描述
如何通过 git pull
获取即将更新(或刚刚更新)的文件列表,以便我可以解析它们并采取适当的措施脚本?
接受的答案是显示我可以得到提交列表
git fetch&& git log master..origin / master
但这对我并不好,因为我需要一个列表文件和我的脚本不能假定分支是 master
或者当前分支正在跟踪 origin / master
。
通过一些实验(和@乔纳森的评论),我发现
git fetch&& git diff master master / master --name-only
几乎就在那里,但现在我需要找到一种获取当前分支及其跟踪的方法,以便我可以执行如下所示的操作(python):
git fetch& git diff%s%s --stat%(this_branch,tracked_branch)
我感觉自己是那里的大多数人,因为现在我只需要知道如何获得当前分支以及它正在跟踪什么,但是我已经给出了更广泛的背景,希望有人知道更多解决这个问题的简单方法( git incoming --files
会很好;)
git获取&& git diff --name-only ..origin
templates / shows / showBase.html
templates / shows / showList.html
templates / shows / showListEntry.htm
或者如果您想分类为单个提交,您可以使用whatchanged:
git fetch&& git whatchanged --name-only ..origin
commit fcb1b56d564fe85615ecd6befcd82f6fda5699ae
作者:Grambo< email @ email>
日期:星期一12月12日23:36:38 2011 +0000
挂钩我已经看到了这个按钮,直到Review Show对话框
模板/shows/showBase.html
模板/ shows / showList.html
模板/ shows / showListEntry.htm
提交xasdasdsada ......
code>
How do I get the list of files that are about to be updated (or were just updated) by git pull
so i can parse them and take appropriate action in a script?
The accepted answer to this similar looking question showed me that I can get a list of commits with
git fetch && git log master..origin/master
but this is no good for me because I need a list of files, and my script cannot assume that the branch is master
or that the current branch is tracking origin/master
.
Through a little experimentation (and @Jonathan's comment), I have found that
git fetch && git diff master origin/master --name-only
is nearly there, but now I need to find a way to get the current branch and what it's tracking so that I can execute something like this (python):
"git fetch && git diff %s %s --stat" % (this_branch, tracked_branch)
I feel like I'm most of the way there, as now I only really need to know how to get the current branch and what it's tracking, but I've given a wider context in the hope that someone knows a much simpler way of solving this (git incoming --files
would be nice ;)
Assuming you know the name of the remote (in my examples, origin) then you could simply go:
git fetch && git diff --name-only ..origin
templates/shows/showBase.html
templates/shows/showList.html
templates/shows/showListEntry.htm
Or if you wanted to sort into individual commits, you could use whatchanged:
git fetch && git whatchanged --name-only ..origin
commit fcb1b56d564fe85615ecd6befcd82f6fda5699ae
Author: Grambo <email@email>
Date: Mon Dec 12 23:36:38 2011 +0000
Hooked "I've Seen This" button up to "Review Show" dialog
templates/shows/showBase.html
templates/shows/showList.html
templates/shows/showListEntry.htm
commit xasdasdsada......
这篇关于如何在不知道分支名称或跟踪内容的情况下通过`git pull`获取要更新的文件列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!