简体   繁体   English

获取最近推送到远程Git分支的文件列表

[英]Get list of files to recently pushed to remote Git branch

How do I get a list of files that have been recently pushed to a remote branch using Git? 如何获取最近使用Git推送到远程分支的文件列表? Or is there any way to list out remote branch files? 还是有什么办法列出远程分支文件?

I googled, but I do not get suggestion. 我用谷歌搜索,但没有得到建议。

The following are strictly command-line solutions that don't use the TortoiseGit GUI client. 以下是严格的命令行解决方案,它们不使用TortoiseGit GUI客户端。

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. 要查看哪些文件已被推送到远程分支,只需从远程获取最新更改,然后使用git log --name-statusgit diff获取自上次以来已更改/添加/删除的文件的列表。从远程获取更改。

Using git diff 使用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. 请注意,仅当reflog中分支的条目超过1个时,才能在reflog语法<branch>@{n}中使用diff 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

$ 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. 同样,仅当引用日志中分支的条目超过1个时,才使用引用日志语法<branch>@{n} 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM