美文网首页Git使用
git创建新分支

git创建新分支

作者: longer冯 | 来源:发表于2016-03-30 11:32 被阅读1072次

1.直接创建本地新分支

  • git branch [newBranchName]
  • git checkout -b [newBranchName] //创建并切换到新分支

2.从远程拷贝分支到本地新分支

  • git checkout -b [newBranchName] origin/[branchName]

3.在远程创建新分支(从本地上传)

  • 3.1 在 github 上创建对应的仓库

  • 3.2 将本地仓库跟远程关联
    git remote add origin git@github.com:userName/CategoryName.git

  • 3.3 提交本地仓库
    git push -u origin 'BranchName'

4.本地没有仓库,从远程拷贝仓库

  • 在本地mkdir一个目录;
  • cd到新建的目录,直接从远程clone :
    git clone git@github.com:userName/CategoryName.git
  • 如果远程仓库含有多个分支,拷贝后本地只能看到master分支,要切换其他的分支的话,要使用第2步骤的方法,但是创建分支前最好还是git branch -r查看下远程分支;

相关文章

网友评论

    本文标题:git创建新分支

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