谢谢你的帮助.
我在我的本地机器(mac osx lion)上有一个git repo,我正试图用Ubuntu推送到我的ec2实例.
在我做过的ec2服务器上:
cd /u/apps
mkdir stuff.git
cd stuff.git
git init --bare
git update-server-info
Run Code Online (Sandbox Code Playgroud)
在我的本地机器上,我有一个文件夹'stuff',它只有一个文本文件.
cd stuff
git init
git add .
git commit -m "initial commit"
git remote add origin user@111.111.111.111:/u/apps/stuff.git
git push origin master
Counting objects: 6, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 477 bytes, done.
Total 4 (delta 0), reused 0 (delta 0)
To user@111.111.111.111:/u/apps/stuff.git
95d5ae5..4b5a30f master -> master
Run Code Online (Sandbox Code Playgroud)
一切似乎都很好但是当我检查服务器时,没有添加名为"hello.txt"的新文本文件.我只看到:
/u/apps/stuff.git$ ls
branches config description HEAD hooks info objects refs
Run Code Online (Sandbox Code Playgroud)
关于我可能忽略的任何想法?
干杯
是的,您没有看到文件,因为您创建了一个git init --bare应该是的裸仓库().光秃秃的回购没有工作树.
如果您尝试从特定路径获取文件,则必须从服务器上的裸存储库中获取该文件,并且必须设置一个post-receive hook并将其签出.post receive hook将具有以下内容:
GIT_WORK_TREE=/path/where/to/checkout git checkout -f
Run Code Online (Sandbox Code Playgroud)
(如果需要,也可以从服务器上的repo手动运行.)