2017-09-26 108 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