git log --graph --decorate --pretty=oneline --abbrev-commit --patch --full-history --follow -- "${FileP}"
印刷
* b8800d8 (HEAD -> master, origin/master, origin/HEAD) chore(export): exported to repo
| diff --git a/DotFilesSrc/DotFileTools/Linux/RepositoryTree/Zathura/zathurarc b/DotFilesSrc/DotFileTools/Linux/RepositoryTree/Zathura/zathurarc
| index c15b225..44691e8 100644
| --- a/DotFilesSrc/DotFileTools/Linux/RepositoryTree/Zathura/zathurarc
| +++ b/DotFilesSrc/DotFileTools/Linux/RepositoryTree/Zathura/zathurarc
| @@ -1,2 +1,2 @@
| include Config.txt
| -include SolarizedDark.txt
| +include SolarizedLight.txt
...
* 300d6c6 chore(source): dirty state
| diff --git a/DotFilesSrc/DotFileTools/RepositoryTree/Zathura/zathurarc b/DotFilesSrc/DotFileTools/Linux/RepositoryTree/Zathura/zathurarc
| similarity index 100%
| rename from DotFilesSrc/DotFileTools/RepositoryTree/Zathura/zathurarc
| rename to DotFilesSrc/DotFileTools/Linux/RepositoryTree/Zathura/zathurarc
...
* 1c2327b chore: initial
diff --git a/DotFilesSrc/DotFileTools/RepositoryTree/Zathura/zathurarc b/DotFilesSrc/DotFileTools/RepositoryTree/Zathura/zathurarc
new file mode 100644
index 0000000..c15b225
--- /dev/null
+++ b/DotFilesSrc/DotFileTools/RepositoryTree/Zathura/zathurarc
@@ -0,0 +1,2 @@
+include Config.txt
+include SolarizedDark.txt
它显示所有提交中文件的更改。
我怎样才能显示上述信息,但只针对一次提交说使用哈希提交b8800d8
(可以是任何取决于提交的哈希)如下
* b8800d8 (HEAD -> master, origin/master, origin/HEAD) chore(export): exported to repo
| diff --git a/DotFilesSrc/DotFileTools/Linux/RepositoryTree/Zathura/zathurarc b/DotFilesSrc/DotFileTools/Linux/RepositoryTree/Zathura/zathurarc
| index c15b225..44691e8 100644
| --- a/DotFilesSrc/DotFileTools/Linux/RepositoryTree/Zathura/zathurarc
| +++ b/DotFilesSrc/DotFileTools/Linux/RepositoryTree/Zathura/zathurarc
| @@ -1,2 +1,2 @@
| include Config.txt
| -include SolarizedDark.txt
| +include SolarizedLight.txt
答案1
根据man git-log
,这可以通过指定要比较的两个提交来完成,用省略号分隔...
您可以使用符号指定提交HEAD~
,或者使用提交哈希。
要仅显示最后一次提交的信息,命令是
git log --graph --decorate --pretty=oneline --abbrev-commit --patch --full-history --follow HEAD...HEAD~1 -- "${FileP}"
如果您确实希望通过仅提供单个提交哈希来执行此操作,则以下 Bash 函数应该可以工作。
commitlog() {
PREVIOUS_COMMIT=$(git log --oneline | awk '{print $1}' | grep -A 1 "$1" | tail -n 1)
git log --graph --decorate --pretty=oneline --abbrev-commit --patch --full-history --follow "$1"..."$PREVIOUS_COMMIT" -- "$2"
}
一旦声明完毕,你可以使用
commitlog b8800d8 "${FileP}"
其中b8800d8
是提交哈希,FileP
是包含文件名的变量。
答案2
git log <the rest of your flags> -1 b8800d8 -- "${FileP}"
b8800d8
使其从该次提交开始并将-1
输出限制为第一次提交。