Git是一款强大的版本管理工具,它可以帮助我们跟踪文件的更改,以及查看提交了哪些文件。呢?
使用git log命令
我们可以使用git log命令来查看git提交了哪些文件,它可以显示提交者、提交时间、提交的注释等信息。 例如,我们可以使用git log命令查看最近的提交:
$ git log commit 8f9c3c1a4d9b5b7e06b9e6c8e2a1f3e4f2a4e5f6 Author: John DoeDate: Thu Nov 19 11:11:11 2020 -0800 Add new feature commit 6f8e7d6c5b4a3b2a1b0c9d8e7f6e5f4d3c2b1a0 Author: Jane Doe Date: Wed Nov 18 10:10:10 2020 -0800 Fix bug
从上面的输出可以看出,最近的提交是John Doe在2020年11月19日11时11分11秒提交的新特性,以及Jane Doe在2020年11月18日10时10分10秒提交的修复bug。
使用git show命令
Git show命令可以显示提交的详细信息,包括提交的文件、提交的补丁等。 例如,我们可以使用git show命令查看某个提交的详细信息:
$ git show 8f9c3c1a4d9b5b7e06b9e6c8e2a1f3e4f2a4e5f6 commit 8f9c3c1a4d9b5b7e06b9e6c8e2a1f3e4f2a4e5f6 Author: John DoeDate: Thu Nov 19 11:11:11 2020 -0800 Add new feature diff --git a/file1.txt b/file1.txt new file mode 100644 index 0000000..1234567 --- /dev/null +++ b/file1.txt @@ -0,0 +1,3 @@ +This is a new file +It has been added to the repository +It is a great addition diff --git a/file2.txt b/file2.txt new file mode 100644 index 0000000..1234567 --- /dev/null +++ b/file2.txt @@ -0,0 +1,3 @@ +This is another new file +It has been added to the repository +It is a great addition
从上面的输出可以看出,John Doe在2020年11月19日11时11分11秒提交了两个文件:file1.txt和file2.txt。
使用git diff命令
Git diff命令可以比较两个提交之间的差异,从而查看提交了哪些文件。 例如,我们可以使用git diff命令比较两个提交之间的差异:
$ git diff 8f9c3c1a4d9b5b7e06b9e6c8e2a1f3e4f2a4e5f6 6f8e7d6c5b4a3b2a1b0c9d8e7f6e5f4d3c2b1a0 diff --git a/file1.txt b/file1.txt index 1234567..8901234 100644 --- a/file1.txt +++ b/file1.txt @@ -1,3 +1,4 @@ This is a new file It has been added to the repository It is a great addition +This is an update to the file diff --git a/file2.txt b/file2.txt index 1234567..8901234 100644 --- a/file2.txt +++ b/file2.txt @@ -1,3 +1,4 @@ This is another new file It has been added to the repository It is a great addition +This is an update to the file
从上面的输出可以看出,John Doe和Jane Doe在两次提交之间更新了两个文件:file1.txt和file2.txt。
以上就是的方法。我们可以使用git log、git show和git diff命令查看git提交了哪些文件,这些命令可以帮助我们跟踪文件的更改,以及查看提交了哪些文件。