With GitHub how do I push all branches when adding an existing repo?

GitGithub

Git Problem Overview


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 [email protected]: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?

Git Solutions


Solution 1 - Git

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.

Solution 2 - Git

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionkipperView Question on Stackoverflow
Solution 1 - GitVonCView Answer on Stackoverflow
Solution 2 - GitIain HunterView Answer on Stackoverflow