简体   繁体   English

如何在gitHub上将现有的本地分支推送到远程?

[英]how to push an existing local branch to remote at gitHub?

I'm using sourceTree. 我正在使用sourceTree。

How can I push an existing local project (branch) to 如何将现有的本地项目(分支)推送到

a remote Gitbug repository I won? 我赢了一个远程Gitbug存储库?

I try and get this error: 我尝试得到这个错误:

git -c diff.mnemonicprefix=false -c core.quotepath=false push -v --tags --set-upstream memPic master:master 
Pushing to https://github.com/elad2109/memPic.git
To https://github.com/elad2109/memPic.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/elad2109/memPic.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Completed with errors, see above

but anyway I'm not sure what are the required steps? 但无论如何我不确定所需的步骤是什么?

This is not a github problem but a git problem. 这不是github问题,而是git问题。 You can't make a non-fast-forward push without merging/rebasing. 如果没有合并/变基,则无法进行非快进。 Please check the corresponding parts of the documentation. 请检查文档的相应部分。

This site is a great help for understanding the problem! 这个网站对理解这个问题很有帮助!

So you basically either have to git pull or git pull --rebase . 所以你基本上要么必须git pullgit pull --rebase

This is failing because the tip of your branch is behind its remote. 这是失败的,因为你的分支的尖端在它的遥控器后面。 This might happen if there was a fetch without a rebase. 如果没有rebase的提取,可能会发生这种情况。

There are two ways to fix. 有两种方法可以解决。 To keep the remote changes add git rebase , before your command. 要保持远程更改,请在命令之前添加git rebase To discard the other changes (not recommended) add a -f to your push command. 要丢弃其他更改(不推荐),请在push命令中添加-f

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

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