131

I created a new GitHub repo - I want to put my existing repo there.
I followed the instructions:

cd existing_git_repo
git remote add origin git@github.com:acme-org/myprj.git
git push origin master

This only pushes the master branch to GitHub.
How do I push everything (including all branches) in my existing repo to my new GitHub repo?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
kipper
  • 1,313
  • 2
  • 9
  • 4
  • Note: you also have `git push --follow-tags` with git 1.8.3+ (May 2013). See [my edited answer below](http://stackoverflow.com/a/4886153/6309) – VonC Mar 14 '14 at 06:28

2 Answers2

249

Note: git push --all won't push your tags, only your branches.

git push --all
git push --tags

would really push everything. See also "Set up git to pull and push all branches".
Don't forget the --dry-run option to make some test before actually pushing everything.
See also GitHub help "Working with remotes" to set your origin to your GitHub remote repo.


As mentioned in "How to make “git push” include tags within a branch?", git 1.8.3+ (May 2013) introduced:

git push --follow-tags

This won't push all the tags, but only the ones accessible from the branch(es) HEAD(s) you are pushing.

That can help keeping that operation (pushing commits and tags) done with one command instead of two.

Git 2.4.1+ (Q2 2015) will introduce the option push.followTags.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • This appears not to work when you want to push to another remote (instead of origin), it only pushes my current branch. – Aloys Feb 05 '13 at 18:29
  • @Aloys that would depend on your git version and current default push policy: http://stackoverflow.com/questions/10002239/difference-between-git-checkout-track-origin-branch-and-git-checkout-b-branch/10002469#10002469 – VonC Feb 05 '13 at 19:06
  • If you want to push remote branches as well use `--mirror` – BFar Jan 21 '17 at 02:14
24

The accepted answer isn't quite right, or at least it didn't work for me. I needed to specify the remote repo as well, eg:

git push origin --all
Iain Hunter
  • 4,319
  • 1
  • 27
  • 13