我一直在四處搜尋以找出如何解決此問題,但似乎無法找到適合我的任何內容。所以我想我會問你。即使遠程設置爲裸設備,無法推送到遠程存儲庫
我最近學會了如何使用git進行源代碼控制,並決定我想開始將它用於我已經構建的網站。我有網站的服務器(不是我自己的,從arvixe購買服務器空間)已經安裝了git。我開始(通過SSH)將我的主文件夾和運行
git init
設置,然後我想添加的所有我已經有文件夾中的文件與git所以我跑:
git add .
然後提交它們:
git commit .
我希望能夠從我的筆記本電腦推到服務器,所以我這樣做是爲了得到一個純倉庫:
git init --bare
(我在google搜索了這個問題後發現它在其他情況下有效。在此之前,我嘗試通過ssh檢查一個虛擬分支,但是當我做到這一點時,從筆記本電腦到服務器的任何事情都沒有改變。)
之後,我通過ssh和sourcetree將存儲庫克隆到我的筆記本電腦上。當我把我的筆記本電腦的變化和嘗試將它們推送到遠程的回購我收到此錯誤信息:
stdin: is not a tty
/etc/bashrc: line 100: $HISTFILE: ambiguous redirect
remote: error: refusing to update checked out branch: refs/heads/master[K
remote: error: By default, updating the current branch in a non-bare repository[K
remote: error: is denied, because it will make the index and work tree inconsistent[K
remote: error: with what you pushed, and will require 'git reset --hard' to match[K
remote: error: the work tree to HEAD.[K
remote: error: [K
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to[K
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into[K
remote: error: its current branch; however, this is not recommended unless you[K
remote: error: arranged to update its work tree to match what you pushed in some[K
remote: error: other way.[K
remote: error: [K
remote: error: To squelch this message and still keep the default behaviour, set[K
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.[K
To ssh://[email protected]/home/ihlenfmt
! [remote rejected] master -> master (branch is currently checked out)
我很新與git所以它極有可能我做了一些愚蠢的事。任何人都能看到我出錯的地方嗎?
「這個我試過檢查出通過ssh的虛擬分支,但是當我這樣做什麼,我從我的筆記本電腦推到了服務器實際上改變任何東西。之前」這是否意味着你在現有的倉庫中運行'git init --bare'?現有的存儲庫將不能進行裸這種方式。相反,請在新目錄中運行該命令。 – Chris
同意@克里斯,或者您可以通過刪除所有文件和目錄(除'.git'),移動.git'的'所有內容到項目的根把非裸露回購成裸露的回購協議,刪除' .git'並設置'core.bare'爲'真'的配置(詳見這個答案http://stackoverflow.com/a/2200662/1157272通過@約爾格-W-午報) – joran