问题
How do I get a list of files that have been recently pushed to a remote branch using Git? Or is there any way to list out remote branch files?
I googled, but I do not get suggestion.
回答1:
The following are strictly command-line solutions that don't use the TortoiseGit GUI client.
To see what files have been pushed to a remote branch, just fetch the latest changes from the remote, then use git log --name-status
or git diff
to get a list of files that have been changed/added/deleted since you last fetched changes from the remote.
Using git diff
$ git fetch origin
$ git diff origin/master@{1} origin/master --name-status
A hello.txt
Note that using diff
with the reflog syntax <branch>@{n}
here will only work if there are more than 1 entry for the branch in the reflog. Otherwise, you'll get this error:
$ git diff origin/master@{1} origin/master --name-status
fatal: Log for 'origin/master' only has 1 entries.
Using git log
$ git log --oneline --graph --name-status origin/master@{1}..origin/master
* 6e6ce69 Add hello.txt
A hello.txt
Again, using the reflog syntax <branch>@{n}
will only work if there are more than 1 entry for the branch in the reflog. If you don't mind seeing the entire history for the branch, then you can just use this instead:
$ git log --oneline --graph --name-status
* 952e133 Add Bash alias for `pbcopy` (OS X)
| M osx/.bash_profile
* c843ea2 Set Vim column limit to 80 (OS X)
| M osx/.vimrc
* 320ed55 Add "Base16 Dark Tomorrow" Sublime Text theme (OS X)
| M editors/sublime-text/Preferences.sublime-settings
* ffff5a5 Add Bash configuration for Scala
| M osx/.bash_profile
* 1b7f496 Add alias for Dr Java to Bash config (OS X)
| M osx/.bash_profile
* 475593a Add global .gitignore file for OS X
| M osx/.gitconfig
| A osx/.global-gitignore
* 7668f34 Modify Bash config to use Homebrew recommended PATH
| M osx/.bash_profile
来源:https://stackoverflow.com/questions/23932860/get-list-of-files-to-recently-pushed-to-remote-git-branch