我一直在四处搜寻以找出如何解决此问题,但似乎无法找到适合我的任何内容。所以我想我会问你。即使远程设置为裸设备,无法推送到远程存储库
我最近学会了如何使用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