使用 Git 从之前的提交分支 [英] Branch from a previous commit using Git
本文介绍了使用 Git 从之前的提交分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我有 n 个提交,我如何从 n-3 个提交分支?
If I have n commits, how can I branch from the n-3 commit?
我可以看到每次提交的哈希值.
I can see the hash of every commit.
推荐答案
您可以通过哈希创建分支:
You can create the branch via a hash:
git branch branchname <sha1-of-commit>
或者通过使用符号引用:
Or by using a symbolic reference:
git branch branchname HEAD~3
要在创建分支时检出分支,请使用
To checkout the branch when creating it, use
git checkout -b branchname <sha1-of-commit or HEAD~3>
这篇关于使用 Git 从之前的提交分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文