如何从git log中检出git中的特定版本? [英] How to checkout a particular version in git from git log?
问题描述
我的git日志显示为:
在此处输入代码
[git_trial] $ git log
commit 4c5bc66ae50780cf8dcaf032da98422aea6e2cf7
作者:king< king@king.ap.com>
日期:星期四六月30 15:09:55 2011 +0530
这是第三次提交
提交8072be67ddd310bc200cab0dccb8bcb2ec4f922c
作者:king< king@king.ap.com>
日期:星期四六月30 14:17:27 2011 +0530
这是第二次提交
提交3ba6ce43d500b12f64368b2c27f35211cf189b68
作者:king< king@king.ap.com>
日期:星期四六月30 14:00:01 2011 +0530
这是file1的第一个git提交
问题1)现在如何结帐只有我的第一个版本?
问题2)当我这样做时,git只登录File1,为什么只显示第一次提交?
[git_trial] $ git checkout 3ba6ce43d500b12f64368b2c27f35211cf189b68
注意:移到不是本地分支的3ba6ce43d500b12f64368b2c27f35211cf189b68
如果你想从这个结账中创建一个新的分支,你可以这样做
(现在或以后)再次使用-b和checkout命令。例如:
git checkout -b< new_branch_name>
[git_trial] $ git log File1
commit 3ba6ce43d500b12f64368b2c27f35211cf189b68
作者:king< king@king.ap.com>
日期:星期四6月30日14:00:01 2011 +0530
这是file1的第一个git提交
git checkout sha-of-commit
来检出提交已经有了。 但是你不能提交任何东西(因为你不在分支中,你在静态提交中)。
如果您需要在该提交之上提交任何内容,则需要使用 git checkout sha-of-commit -b testing -a-commit
。
git log< file>
只显示影响该文件的提交。 / p>
My git log is showing something as:
enter code here
[git_trial]$ git log
commit 4c5bc66ae50780cf8dcaf032da98422aea6e2cf7
Author: king <king@king.ap.com>
Date: Thu Jun 30 15:09:55 2011 +0530
This is third commit
commit 8072be67ddd310bc200cab0dccb8bcb2ec4f922c
Author: king <king@king.ap.com>
Date: Thu Jun 30 14:17:27 2011 +0530
This is the second commit
commit 3ba6ce43d500b12f64368b2c27f35211cf189b68
Author: king <king@king.ap.com>
Date: Thu Jun 30 14:00:01 2011 +0530
This is the first git commit for file1
Question 1) Now how to checkout only my first version? Question 2) Also when i do, git log on only File1, why does it show only first commit?
[git_trial]$ git checkout 3ba6ce43d500b12f64368b2c27f35211cf189b68
Note: moving to "3ba6ce43d500b12f64368b2c27f35211cf189b68" which isn't a local branch
If you want to create a new branch from this checkout, you may do so
(now or later) by using -b with the checkout command again. Example:
git checkout -b <new_branch_name>
[git_trial]$ git log File1
commit 3ba6ce43d500b12f64368b2c27f35211cf189b68
Author: king <king@king.ap.com>
Date: Thu Jun 30 14:00:01 2011 +0530
This is the first git commit for file1
You can checkout a commit using git checkout sha-of-commit
which you already have.
But you cannot commit anything (as you're not in a branch, you're in a static commit).
If you need to commit anything on top of that commit, you need to check it out into a branch using git checkout sha-of-commit -b testing-a-commit
.
git log <file>
only shows commits that affect that file.
这篇关于如何从git log中检出git中的特定版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!