使用GitHub时,如何在添加现有回购时推送所有分支? [英] With GitHub how do I push all branches when adding an existing repo?

查看:69
本文介绍了使用GitHub时,如何在添加现有回购时推送所有分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个新的GitHub回购 - 我想把我现有的回购存在那里。

我遵循指示:

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

这只会将主分支推送到GitHub。

如何将我现有仓库中的所有分支(包括所有分支)推送到我的新GitHub仓库?

解决方案

注意:git push --all不会推送您的标签,只能是您的分支。 b

  git push --all 
git push --tags

会真正推动一切。另请参阅设置git以拉取所有分支 a>。


不要忘记 - 干运行 选项,在实际推送所有内容前进行一些测试。

另请参阅GitHub帮助
使用遥控器将您的起源设置为您的GitHub远程回购。






正如

<$ p

如何使git push在分支中包含标签? $ p $ git push --follow-tags




这不会推送所有的标签,但只能从您正在推送的分支(HEAD)中访问的标签。

这可以帮助保持该操作(推送提交标签)完成一个命令广告两个。

Git 2.4.1+(Q2 2015)将会引入 push.followTags / p>

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?

解决方案

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.

这篇关于使用GitHub时,如何在添加现有回购时推送所有分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆