如何在github中查看上次拉动对本地文件所做的更改?

ca1c2owp  于 2022-10-23  发布在  Git
关注(0)|答案(1)|浏览(140)

如何在github和windows中查看上次拉动对本地文件所做的更改?上次拉取所做的更改可能包括一次拉取多个提交所做的修改。

qq24tv8q

qq24tv8q1#

您可以检查remote分支的reflog,以查看提拉之前的提交:

$ git reflog origin/master              # <- 'origin/master', not 'master'
3ab2281 refs/remotes/origin/master@{0}: pull: fast-forward  # <-last pull
3cdd5d1 refs/remotes/origin/master@{1}: fetch: fast-forward # <-previous pull
cda1bbd refs/remotes/origin/master@{2}: fetch: fast-forward
5b18e70 refs/remotes/origin/master@{3}: fetch: fast-forward
...

然后,您可以查看最后列出的两个提交之间的差异:

$ git diff 3cdd5d1 3ab2281         # usual diff in terminal

# or

$ git difftool -d 3cdd5d1 3ab2281  # graphical diff viewer

要简单地查看已修改文件的列表,以及A dded、M odified或D eleted的小标记:

$ git diff --name-status 3cdd5d1 3ab2281
M       .travis.yml
M       Documentation/RelNotes/2.10.2.txt
M       Documentation/RelNotes/2.11.0.txt
M       Documentation/config.txt
M       Documentation/diff-config.txt
...

[edit]origin/master@{xx}实际上是指向“reflog中第xx个条目”的有效方法,因此您还可以运行:

git diff origin/master@{1} origin/master
git difftool -d origin/master@{1} origin/master
git diff --name-status origin/master@{1} origin/master
...

相关问题