git: how to turn a clone into a new branch?

This question already has an answer here:

  • Move the most recent commit(s) to a new branch with Git 9 answers
  • How can I push my changes to a remote branch 5 answers

  • Assuming you have't pushed anything yet and your history looks something like

    A -- B -- C -- D -- E
    ^                   ^
    |                   |
    origin/master       master
    

    You can just do the following:

    git branch feature
    git reset origin/master
    

    to get this:

    A -- B -- C -- D -- E
    ^                   ^
    |                   |
    |                   feature
    origin/master,master
    
    链接地址: http://www.djcxy.com/p/4290.html

    上一篇: 主人在起源/主人之前是1

    下一篇: git:如何将一个克隆变成一个新的分支?