2017-07-24 69 views
0

後會得到拒絕合併錯誤,它會創建一個visual studio代碼擴展名。當我運行「git pull origin master」

但在設置github存儲庫時出現錯誤。 當我運行「混帳拉起源大師」,我得到錯誤「拒絕合併無關的歷史」

這裏有我喲代碼運行後,運行和Git命令創建分機:

git add . 
git commit -m "Initial Commit" 

創建回購在github

git remote add origin https://github.com/lae0901/static-site-hero.git 
git push origin master 
git pull origin master 

github是完全混淆了我。如何合併起源和主?

感謝,

這裏有我正在運行的所有步驟: 打開Windows

使Node.js的命令提示符 - 運行喲代碼創建擴展

yo code 

? What type of extension do you want to create? New Extension (JavaScript)
? What's the name of your extension? static site hero
? What's the identifier of your extension? static-site-hero
? What's the description of your extension? static site hero
? What's your publisher name (more info: https://code.visualstudio.com/docs/tools/vscecli#_publishing-extensions)? lae0
901
? Initialize a git repository? (Y/n) Y

- cd到擴展目錄

cd static-site-hero 

git status 
git add . 
git commit -m "Initial Commit" 

登錄到github.com 創建一個新的存儲庫 集名稱作爲擴展名。添加許可證 - MIT 點擊「創建庫」 點擊下載下拉找到回購的URL

git remote add origin https://github.com/lae0901/static-site-hero.git 

- 檢查的ConfigEd正確:

git remote --verbose 

- 這是所顯示的內容

C:\Users\Steve\static-site-hero>git remote --verbose
origin https://github.com/lae0901/static-site-hero.git (fetch)
origin https://github.com/lae0901/static-site-hero.git (push)

- 首先我git push origin master。但是失敗:

C:\Users\Steve\static-site-hero>git push origin master 

https://github.com/lae0901/static-site-hero.git

! [rejected] master -> master (non-fast-forward) error: failed to push some refs to ' https://github.com/lae0901/static-site-hero.git ' 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 origin master也失敗

C:\Users\Steve\static-site-hero> git pull origin master 

warning: no common commits remote: Counting objects: 3, done. remote: Compressing objects: 100% (2/2), done. remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 Unpacking objects: 100% (3/3), done. From https://github.com/lae0901/static-site-hero * branch master -> FETCH_HEAD * [new branch] master -> origin/master fatal: refusing to merge unrelated histories

如何糾正這一錯誤?爲什麼拒絕合併無關的歷史?

回答

1

發生這種情況是因爲Github存儲庫在創建許可證時有一個初始提交。該許可證提交不在您的本地分支中,因此GitHub認爲您有兩個不相關的項目,您不能推或拉。理想情況下,在您將回購推送到GitHub之前,您並未從GitHub上提交。儘管如此,所有的都不會丟

你可以拉從Github上提交併告訴它忽略不相關的歷史與:

git pull origin master --allow-unrelated-histories 

這將在許可證到本地分支合併。那麼你應該可以推到Github。

+0

使用喲代碼來創建vscode擴展並將其鏈接到一個github上存儲庫時修改後的步驟: '運行喲代碼以創建擴展 CD <擴展文件夾名稱> GIT中添加。 git commit -m「初始提交」 在github上創建回購。回購的名稱是擴展名文件夾名稱。 git remote add origin https://github.com/ /.git git pull原點主 - 允許無關歷史 git push原點主 ' –

相關問題