2017-09-26 98 views
1

我尝试下面的命令和失败:混帐中心库创建失败

> cd SecurityAlert/ 
> sudo apt-get install git 
> git init 
> git add . 
> git config --global user.email "[email protected]" 
> git config --global user.name "user" 
> git commit -m "First commit" 
> git remote add origin https_link_github.com/user/SecurityAlert 
> git push origin master 

To https_link_github.com/user/SecurityAlert
! [rejected] master -> master (non-fast-forward)

error: failed to push some refs to 'https_link_github.com/sandeepmhptr/SecurityAlert' hint: Updates were
rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

git pull 

There is no tracking information for the current branch. Please specify which branch you want to merge with. See git-pull(1) for details git pull

If you wish to set tracking information for this branch you can do so with: git branch --set-upstream-to=origin/ master

> git remote add -v 

> git remote -v 

回答

0

你需要改变你把在远程的URL。

您使用:

> git remote add origin https_link_github.com/sandeepmhptr/SecurityAlert 

这应该是:

> git remote add origin https://github.com/sandeepmhptr/SecurityAlert 

然后,只要您设置您的GitHub库正常,你应该能够好推动 - 但是你有问题推动和错误消息,使它看起来像已经在您的远程回购提交(origin)。

对于推动现有回购到一个新的远程Github上,您所使用的命令,在GitHub库必须已被初始化没有添加README.md.gitignore文件给它。如果您确实添加了这些内容,那么最简单的方法就是删除回购站并在第一次推送前再次创建它,而无需添加任何文件。在这种情况下,请确保使用完全相同的名称重新制作它,或者更新URL。

另一种选择可能是强制推送,它基本上会用本地回购的历史覆盖远程回购。如果这是一个全新的回购,并且没有其他人下载它,那是另一种选择。


如果远程回购有一些已经提交,你想保留,那么你就需要同步这些到本地回购,然后才能推动。这可以得到非常详细的,具体取决于差异是什么以及你想如何合并历史出来。

+0

远程URL是git remote add origin https://github.com/sandeepmhptr/SecurityAlert,我在这里写过git remote add origin https_link_github.com/sandeepmhptr/SecurityAlert,因为这个站点有些问题,它不允许超过2个网址 – chinmay

+0

嗨,我再次尝试了所有这些步骤,并且它成功了 – chinmay

+0

好吧,看起来好像遥控器已经初始化了一点。我添加了一些更多的信息来澄清答案。如果这确实有帮助,或者回答了您的问题,我将非常感谢复选标记或投票。 – LightCC