所有提交的列表SHA1_HASH

时间:2010-03-27 20:49:38

标签: git

git init
echo 'I am foo' > foo.txt
git add foo.txt # this woould create a git commit object
echo ' I am foo2' > foo.txt
git add foo.txt # this would create another git commit object
git commit -m 'doe' # this would create two git 
                    # objects: one commit object and one tree object

如何获取所有4个提交SHA1_HASH的列表?

cd .git/objects
ls
(master)$ ls -al
total 0
drwxr-xr-x   8 nsingh  staff  272 Mar 27 16:44 .
drwxr-xr-x  13 nsingh  staff  442 Mar 27 16:44 ..
drwxr-xr-x   3 nsingh  staff  102 Mar 27 16:44 37
drwxr-xr-x   3 nsingh  staff  102 Mar 27 16:43 a2
drwxr-xr-x   3 nsingh  staff  102 Mar 27 16:44 e1
drwxr-xr-x   3 nsingh  staff  102 Mar 27 16:42 e6
drwxr-xr-x   2 nsingh  staff   68 Mar 27 16:42 info
drwxr-xr-x   2 nsingh  staff   68 Mar 27 16:42 pack

我可以通过查看文件找到所有4个提交的列表,但必须有更好的方法。

3 个答案:

答案 0 :(得分:2)

尝试git log --pretty=oneline

答案 1 :(得分:2)

git log --format=format:%H将只打印提交哈希值,每行一个。有关格式选项的详细信息,请查看man git-log的{​​{3}}。 --pretty=oneline建议类似,但也会提供提交消息和哈希值。

答案 2 :(得分:0)

如果您只想要缩写的SHA 1,请尝试git log --abbrev-commit --pretty=oneline