使用git检出项目的第一次提交 [英] Checking out a project's first commit with git

查看:128
本文介绍了使用git检出项目的第一次提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种简单的方法来查找具有git历史的项目中的第一次提交的SHA1?

Is there an easy way to find the SHA1 of the first commit in a project with a long history with git?

推荐答案

就在我的HEAD的顶部,这应该获得当前分支的第一个"提交之一.

Just off the top of my HEAD, this should get one of the 'first' commits of the current branch.

git rev-list --reverse HEAD | head -1

(如果分支包含合并在一起的两个不相关的分支,则不能保证将获得哪个根,但是可以使用--date-order选择最早的根.)

(If the branch contiains two unrelated branches which have been merged together, it's not guaranteed which root you will get but you could use --date-order to select the oldest.)

这篇关于使用git检出项目的第一次提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆