美文网首页Git
Git create a new branch from a h

Git create a new branch from a h

作者: JaedenKil | 来源:发表于2019-02-20 11:09 被阅读0次
    • git branch branchName <sha1-of-commit>
    # On master branch
    $ git log --oneline
    37f1ff2 (HEAD -> master) Add file06
    fd92f0a Add file04 and file05
    706ac8d (demo) Add file03
    e62bfba Add file02
    6dd771d Add file01
    
    # Create a new branch named "demo01"
    $ git branch demo01 706ac8d
    
    # Checkout to demo01
    $ git checkout demo01
    Switched to branch 'demo01'
    
    # Om demo01 branch
    $ git log --oneline
    706ac8d (HEAD -> demo01, demo) Add file03
    e62bfba Add file02
    6dd771d Add file01
    
    # On master branch
    $ git log --oneline
    37f1ff2 (HEAD -> master) Add file06
    fd92f0a Add file04 and file05
    706ac8d (demo01, demo) Add file03
    e62bfba Add file02
    6dd771d Add file01
    
    • git checkout -b branchName <sha1-of-commit>
      Which is equivalent to git branch branchName <sha1-of-commit> + git checkout branchName.

    相关文章

      网友评论

        本文标题:Git create a new branch from a h

        本文链接:https://www.haomeiwen.com/subject/ylbcyqtx.html