Git how to checkout a commit of a branch

后端 未结 3 1018
花落未央
花落未央 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条回答
  •  有刺的猬
    2021-02-02 07:07

    git checkout    # non named commit
    git checkout   # named commit
    

    The two lines above will place the HEAD pointer on the given commit. You should know that a branch name is a commit, except it can evolve if you a new commit is added when you're on that branch.

    If you want to place your branch Dev on the commit ad4f43af43e you can do this

    git branch -f Dev ad4f43af43e
    

    Be careful! This is dangerous because you may loose commits

提交回复
热议问题