gpt4 book ai didi

git - 在不知道分支名称或它跟踪的内容的情况下,如何获取将由 `git pull` 更新的文件列表?

转载 作者:IT王子 更新时间:2023-10-29 01:30:50 24 4
gpt4 key购买 nike

如何通过 git pull 获取即将更新(或刚刚更新)的文件列表,以便我可以解析它们并在脚本中采取适当的操作?

this similar looking question 的公认答案向我展示了我可以获得一份提交列表

git fetch && git log master..origin/master

但这对我没有好处,因为我需要一个文件列表,而且我的脚本不能假定分支是 master 或者当前分支正在跟踪 origin/master.

通过一些实验(和@Jonathan 的评论),我发现

git fetch && git diff master origin/master --name-only

快到了,但现在我需要找到一种方法来获取当前分支及其跟踪的内容,以便我可以执行类似这样的操作(python):

"git fetch && git diff %s %s --stat" % (this_branch, tracked_branch)

我觉得我已经完成了大部分工作,因为现在我只需要知道如何获取当前分支以及它正在跟踪什么,但我已经提供了更广泛的上下文,希望有人知道更多解决这个问题的更简单方法(git incoming --files 会很好;)

最佳答案

假设您知道 Remote 的名称(在我的示例中为 origin),那么您可以简单地执行以下操作:

git fetch && 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
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 - 在不知道分支名称或它跟踪的内容的情况下,如何获取将由 `git pull` 更新的文件列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8522619/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com