假設我這樣做。
使用 github
在本地機器上:
git init testrepo在 github 上:在 Web 界面中制作一個 repo test.git pressing buttons
在本地:
cd testrepo
git remote add origin https://github.com/Someuser/test.git
接著:
touch somefile
git add .
git commit -m 'first'
git push -u origin master
一切都很好,我已將我的somefile同步到 github 存盤庫。
使用遠程服務器
在本地機器上:
git init testrepo在遠程機器上:
mkdir test.git
- 在本地:
cd testrepo
git remote add origin remotemachine:~/test.git
接著:
touch somefile
git add .
git commit -m 'first'
git push -u origin master
不好了!..
錯誤資訊。
! [remote rejected] master -> master (branch is currently checked out)
一切看起來都一樣。為什么 github 的行為不同?
或者,補救措施是什么?可選 - 因為您會在下面的問題中看到一堆建議的解決方案,但沒有一個被接受的答案。
我知道這個問題Git push error '[remote rejected] master -> master (branch is currently checked out)'
但是它沒有回答我的問題。
uj5u.com熱心網友回復:
一切看起來都一樣。
只是看起來。確實情況不同。
為什么 github 的行為不同?
因為在 GiHub 沒有分支機構被檢出。GitHub 上的存盤庫是空的(沒有作業樹)。
底線:如果要將遠程存盤庫推送到它應該是裸的。
請參閱有關裸存盤庫的這些問題和答案:
Bare 和非 Bare 存盤庫之間的實際區別是什么?
“git init”和“git init --bare”有什么區別?
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/536307.html
下一篇:Github回購結構建議
