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

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

问题描述

我创建了一个新的 GitHub 存储库 - 我想将我现有的存储库放在那里.
我按照说明操作:

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

这只会将 master 分支推送到 GitHub.
如何将现有存储库中的所有内容(包括所有分支)推送到新的 GitHub 存储库?

解决方案

注意:git push --all 不会推送你的标签,只会推送你的分支.

git push --allgit push --tags

真的会推动一切.另请参阅设置 git 以拉取和推送所有分支".
不要忘记 --dry-run 选项,以便在实际推送所有内容之前进行一些测试.
另请参阅 GitHub 帮助
使用遥控器"以将源设置为 GitHub 远程存储库.

<小时>

如何使git push"在分支中包含标签?"中所述,git 1.8.3+(2013 年 5 月)介绍:

git push --follow-tags

<块引用>

这不会推送所有标签,而只会推送可从您推送的分支 HEAD 访问的标签.

这有助于保持操作(推送提交标签)用一个命令而不是两个命令完成.

Git 2.4.1+(2015 年第二季度)将引入选项 push.followTags.

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天全站免登陆