开发者

list of all commits SHA1_HASH

开发者 https://www.devze.com 2022-12-25 01:27 出处:网络
git init echo \'I am 开发者_JAVA百科foo\' > foo.txt git add foo.txt # this woould create a git commit object
git init
echo 'I am 开发者_JAVA百科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

How do I get a list of all 4 commits 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

I can find the list of all 4 commits by looking at file here but there must be a better way.


git log --format=format:%H will print out only the commit hashes, one per line. Take a look at the pretty formats section of man git-log for more info on the format options. The --pretty=oneline suggestion is similar, but will also give you the commit messages as well as the hashes.


Try git log --pretty=oneline.


If you only want the abbreviated SHA 1, try git log --abbrev-commit --pretty=oneline.

0

精彩评论

暂无评论...
验证码 换一张
取 消