Git how to checkout a commit of a branch

后端 未结 3 1078
花落未央
花落未央 2021-02-02 06:10

How can I check out a commit version of a branch in git?

For example, my branch, Dev, has a commit ad4f43af43e. How can I check o

3条回答
  •  萌比男神i
    2021-02-02 06:52

    You can checkout to the commit-sha then, create a new branch (say, feature) from that commit.

    $ git checkout 
    $ git checkout -b feature    # create a new branch named `feature` from the commit
    
    
    # if you want to replace the current branch (say 'develop') with new created branch ('feature') 
    $ git branch -D develop     # delete the local 'develop' branch
    $ git checkout -b develop   # create a new 'develop' branch from 'feature' branch 
    

提交回复
热议问题