Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
413 views
in Technique[技术] by (71.8m points)

git - 使用Git从先前的提交分支(Branch from a previous commit using Git)

If I have n commits, how can I branch from the n-3 commit?

(如果我有n次提交,如何从n-3次提交中分支出来?)

I can see the hash of every commit.

(我可以看到每个提交的哈希值。)

  ask by dole doug translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...