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......
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With