git - 如何从 git log 输出中获取特定的 SHA

标签 git import cygwin logging sha

执行以下命令 git log --before "Feb 01 2011" 返回指定日期之前的所有提交,包括它们的 SHA 我正在尝试编写一个 cygwin 脚本,将我的头与特定月份的最后一次提交同步,而无需我自己查找并输入 SHA。有任何想法吗?谢谢!

最佳答案

只需使用 rev-list 和传递给 log 的相同选项,再加上 -n 1 只返回第一个。

sha1=$(git rev-list --before "Feb 01 2011" -n 1 HEAD)

关于git - 如何从 git log 输出中获取特定的 SHA,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7519725/

相关文章:

Github 存储库未显示最新提交

git - git 有类似 svn_load_dirs.pl 的东西吗?

git - 如何对 git 提交进行分类?

java - 使用 cygwin 从 rJava 安装 jri 会导致错误

python - usr/bin/env : bad interpreter Permission Denied --> how to change the fstab

linux - InetSim 可以与 Cygwin 一起使用吗?

php - 将 Git 与共享托管计划一起使用

python - 导入错误 : No module named schedule

python - Intellij idea 无法识别 python 3 中本地类的导入

java - 无法在 Eclipse 中从 Nvidia Tegra Developer Pack 导入 o​​rg.opencv[...]