Skip to content

Instantly share code, notes, and snippets.

@leviresende
Forked from appleboy/copy_content.mkd
Created July 3, 2020 13:48
Show Gist options
  • Save leviresende/7af830f40b61753ba2c5ccae759d7ddd to your computer and use it in GitHub Desktop.
Save leviresende/7af830f40b61753ba2c5ccae759d7ddd to your computer and use it in GitHub Desktop.
Copy all branch from another repository?

Repository url

origin: https://github.com/appleboy/git-test
remote: https://github.com/appleboy/html5-template-engine

Copy all branch from another repository

# clone origin repo
$ git clone https://github.com/appleboy/git-test
$ cd git-test
# add remote repo url.
$ git remote add html5 https://github.com/appleboy/html5-template-engine.git

show all remote repo

$ git remote -v
html5   https://github.com/appleboy/html5-template-engine.git (fetch)
html5   https://github.com/appleboy/html5-template-engine.git (push)
origin  git@github.com:appleboy/git-test.git (fetch)
origin  git@github.com:appleboy/git-test.git (push)

fetch remote repo data

$ git fetch html5

show all branch info

$ git branch -a

* master                       420f7f5 update test.php
  remotes/html5/master         b6e0324 update html
  remotes/origin/HEAD          -> origin/master
  remotes/origin/master        420f7f5 update test.php

copy html5/master branch to origin repo

$ git checkout -b html5/develop html5/master

show all branch info

$ git branch -a
* html5/develop                b6e0324 update html
  master                       420f7f5 update test.php
  remotes/html5/master         b6e0324 update html
  remotes/origin/HEAD          -> origin/master
  remotes/origin/develop       206c580 some change edit
  remotes/origin/html5/develop b6e0324 update html
  remotes/origin/master        420f7f5 update test.php

push html5/develop to origin server

$ git push origin html5/develop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment