technology:github:拷贝分支到新分支

当我们通过git clone将github上的专案拷贝到本地,有一种情况是 我们想要复制其中的一个分支的内容并放到新建的分支,那么该怎么做1)

1.查看远程分支 在终端输入git branch -r(输入git branch --all也能查看到)

$ git branch -r
  origin/HEAD -> origin/gh-pages
  origin/gh-pages
  origin/mehmandarov-patch-1
  origin/python-example

2.复制分支到新建分支中 git checkout origin/ch08 -b ch11 比如这里我新建了分支ch11,并把远程分支ch08复制到了ch11

# E: Copy the gh-pages branch to the newly created master branch.
$ git checkout origin/gh-pages -b master
Branch master set up to track remote branch gh-pages from origin.
Switched to a new branch 'master'

3.提交

$ git push origin master
Username for 'https://github.com': songtianlun
Password for 'https://songtianlun@github.com': 
Total 0 (delta 0), reused 0 (delta 0)
remote: 
remote: Create a pull request for 'master' on GitHub by visiting:
remote:      https://github.com/songtianlun/songtianlun.github.io/pull/new/master
remote: 
To https://github.com/songtianlun/songtianlun.github.io.git
 * [new branch]      master -> master

  • technology/github/拷贝分支到新分支.txt
  • 最后更改: 2019/09/15 10:58
  • (外部编辑)