git 使用 GitHub 在添加现有存储库时如何推送所有分支?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4885999/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
With GitHub how do I push all branches when adding an existing repo?
提问by kipper
I created a new GitHub repo - I want to put my existing repo there.
I followed the instructions:
我创建了一个新的 GitHub 存储库 - 我想将我现有的存储库放在那里。
我按照说明操作:
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?
这只会将 master 分支推送到 GitHub。
如何将现有存储库中的所有内容(包括所有分支)推送到新的 GitHub 存储库?
回答by VonC
Note: git push --all won't push your tags, only your branches.
注意: git push --all 不会推送你的标签,只会推送你的分支。
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.
真的会推一切。另请参阅“设置 git 以拉取和推送所有分支”。
不要忘记--dry-run
在实际推送所有内容之前进行一些测试的选项。
另请参阅 GitHub 帮助“使用遥控器”以将源设置为 GitHub 远程存储库。
As mentioned in "How to make “git push” include tags within a branch?", git 1.8.3+ (May 2013) introduced:
如“如何使“git push”在分支中包含标签? 中所述,git 1.8.3+(2013 年 5 月)引入:
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.
这不会推送所有标签,而只会推送可从您推送的分支 HEAD 访问的标签。
That can help keeping that operation (pushing commits andtags) done with onecommand instead of two.
这有助于保持该操作(推送提交和标签)使用一个命令而不是两个命令完成。
Git 2.4.1+ (Q2 2015) will introduce the option push.followTags
.
Git 2.4.1+(2015 年第二季度)将引入选项push.followTags
。
回答by Iain Hunter
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