Push branches to Git

北城余情 提交于 2019-11-29 20:08:58
git push origin <local-branch-name>:<remote-branch-name>

Substitute for <local-branch-name> and <remote-branch-name>. They may be same or different, as you wish.

J-16 SDiZ

As you have set up the remotes already, the command is just

git push origin branch-name

on the first push.

Afterward, using git push origin would push all branches with the matching name on remote.

mturquette

Make sure that your remote URL is using SSH syntax and not just Git protocol syntax. If you run,

git remote show origin

the URL printed should look something like,

git@github.com:yourname/projectname.git

You need the URL too to look like that if you want to be able to push. If you are just a public user (without write access) the URL will look like,

git://github.com/yourname/projectname.git

If yours looks like the latter then you can manually edit it in your projects .git/config file.

if you need to pull any branch code from remotely to locally

$git pull origin branch_name

while if you need to push code to your branch

you need to check is your code successfully save you can check by

$git status

than

$git add -A

after this make commit to your branch

$git commit -m "this is initial change"

than(Last) push your code to your branch by:

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