发布于 2年前

Git切换分支到指定的提交(commit)

Git要切换到指定的提交,先找出提交的commitId

Git查找commitId

$git log
commit cbcf45ec166eee4ca0ade2dc78f1445f7d39f0ab
Author: xxx
Date:  Wed Jan 24 11:29:34 2018 +0800

fix bug1

commit 5fac6c3501e52836a4f60077bca49c93ca40154f
Author: xxx
Date:  Thu Jan 18 23:53:17 2018 +0800

  fix bug 2

commit 226632d1ba5c84c14b17de92a72b47dae166dcab

检出提交

git checkout cbcf45ec166e

一般情况下使用commitId的前十位即可。这种检出提交的方式是没有分支的。

检查提交到新的分支

git checkout -b old-state cbcf45ec166e

-b参数会为提交新建一个分支。

git
©2020 edoou.com   京ICP备16001874号-3