git push vs git push origin <branchname>

匿名 (未验证) 提交于 2019-12-03 01:58:03

问题:

I'm quite new to git. I'm creating a branch and then want to push it to origin. I think that simple issuing git push while standing on my branch should be sufficient. Is it possible to do that (by specifying push.default simple)? Is it reasonable to do that?

回答1:

The first push should be a:

git push -u origin branchname 

That would make sure:

Any future git push will, with that default policy, only push the current branch, and only if that branch has an upstream branch with the same name.
that avoid pushing all matching branches (previous default policy), where tons of test branches were pushed even though they aren't ready to be visible on the upstream repo.



回答2:

First, you need to create your branch locally

git checkout -b your_branch 

After that, you can work locally in your branch, when you are ready to share the branch, push it. The next command push the branch to the remote repository origin and tracks it

git push -u origin your_branch 

Your Teammates/colleagues can push to your branch by doing commits and then push explicitly

... work ... git commit ... work ... git commit git push origin HEAD:refs/heads/your_branch  


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!