之前我使用过Mercurial(Hg),可以在本地PC上做一些事情:
hg clone ssh://peter@hostingcompany.com/~/mysite.com
Run Code Online (Sandbox Code Playgroud)
然后将有一个名为的本地文件夹mysite.com,我可以编辑其内容,提交,并说出hg push并将其推送到服务器.当然,为了让内容显示在"工作目录"中,我将不得不在ssh那里做一个hg up.
使用Git,如果我这样做,在服务器上,做一个
git init
git add .
git commit -m "ok"
Run Code Online (Sandbox Code Playgroud)
在当地的电脑上,做一个
git clone ssh://peter@hostingcompany.com/~/mysite.com
Run Code Online (Sandbox Code Playgroud)
但是当我编辑一个文件时git push ssh://peter@foo.com/~/mysite.com master,它会拒绝它,因为它不是一个"裸存储库".
有办法吗?
hg up- 是的git checkout,以便内容在mysite.com上立即可视(在任何地方使用任何Web浏览器).更新:
看起来通常的做法是推出一个简单的回购......但我们不能使用一个简单的回购并使(2)上面的工作?如果这是一种实用的方式,那么我们不必坚持"推动裸机回购"规则吗?
如果还有其他原因仍然需要在服务器上推送裸机并克隆...那么:
如果服务器有目录,例如~/mysite.com和~/other_folder等,然后在那里应该用于回购mysite.com坐? mysite.com是网站的内容,所以如果我放一个index.html,那么世界上的任何浏览器都可以看到它.那么创建一个裸仓库,~/mysite.com从它上面克隆,在本地PC上,在本地PC上git push <path> master; ssh <path> "cd to that folder and do git checkout to update the content"自动使用1行是不错的?这条线是git push ssh://peter@hostingcompany.com/~/mysite.com master; ssh ssh://peter@hostingcompany.com/~/mysite.com 'git pull; git checkout'吗?
我不知道为什么人们说它不受支持.虽然推荐使用裸仓库,但是你可以通过将receive.denyCurrentBranchconfig变量设置为'ignore'或'warn' 来推送到非裸机,如你所获得的错误消息所示(至少在1.7.1上)试着这样做:
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.
Run Code Online (Sandbox Code Playgroud)
我会说你使用git push进行部署,然后在远程端进行硬重置的工作流正是创建此配置变量的规则的例外.
此外,我还没有亲自尝试过,但是"当前分支"语言意味着您可以推送到未检出但没有任何错误的远程分支,之后您可以在远程执行快速合并结束你的签出分支.
| 归档时间: |
|
| 查看次数: |
743 次 |
| 最近记录: |