简体   繁体   English

“$ git push”branch_name 的致命错误

[英]fatal error with “$ git push ”branch_name"

Why is this not pushing to my newly created branch?为什么这不推送到我新创建的分支?

PS `\team_test> git checkout -b 123123
Switched to a new branch '123123'
PS `> git push
fatal: The current branch 123123 has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin 123123

PS ~> git push --set-upstream origin 123123
Warning: Permanently added the RSA host key for IP address 'bla.bla.bla' to the list of known hosts.
Enumerating objects: 5, done.
Delta compression using up to 8 threads
Writing objects: 100% (3/3), 351 bytes | 175.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (1/1), completed with 1 local object.

I was used to push to origin ( git push --set-upstream origin 123123 ), why can't I just push to my own branch without origin ?我习惯推送到原点( git push --set-upstream origin 123123 ),为什么我不能在没有origin情况下推送到我自己的分支? Why can't I just print "git push" when I'm in my branch?为什么当我在我的分支时不能只打印“git push”?

It doesn't matter that this is "your" branch.这是“你的”分支并不重要。 It is a new branch so it doesn't exist on the remote.这是一个分支,因此它不存在于遥控器上。 Therefore, in order to push, you have to say what you want done with it.因此,为了推动,你必须说出你想用它做什么。 You cannot just say git push .你不能只说git push

You have two choices.你有两个选择。 One is to say every single time what you want done with the branch:一种是每次都说你想用分支做什么:

git push origin 123123

However, it is more convenience to say this, once :但是,这样说更方便,一次

git push -u origin 123123

The -u is a shortcut for setting the upstream. -u是设置上游的快捷方式。 Now you will be able to say git push forever on this branch.现在你可以在这个分支上说git push永远。

You have to do this for every new branch you create on your local repo that you want to push.您必须为要推送的本地存储库上创建的每个新分支执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM