我的笔记本电脑上有一个 Git 存储库,还有一个服务器,很远很远。
我在服务器上做了这个:
$ cd apps
$ mkdir my_beautiful_app
$ git init --bare
在我的笔记本电脑上,我这样做了:
$ cd beautiful_app_dir
$ git remote add website my_user@11.22.33.44:apps/my_beautiful_app
$ git push website master
似乎它正在转移东西,所以我认为这是可行的。但实际上不是。在服务器上,在my_beautiful_app
目录中,我没有项目文件的踪迹。现在我有很多我没有要求的文件和目录:
在服务器上:
$ ls ~/apps/my_beautiful_app
branches config description HEAD hooks info objects refs
嗯,这是出乎意料的。为什么我会出现这种奇怪的行为?如何让服务器上的目录与我的本地目录同步?
编辑:
好的,我尝试了同样的事情,但没有--bare
选择。这是我得到的:
$ git push website master
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error:
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some
remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.