Git远程存储库(包含文件?) [英] Git remote repository (with files?)
问题描述
我有一个远程Web服务器,可以完全访问(ssh,git等)。我希望能够编辑我的计算机上的文件并将它们推送到远程服务器。当我使用裸存储库时,它不会更改文件,但是当我使用非裸存储库时,它会发出以下消息:
remote:error:拒绝更新签出分支:refs / heads / master
remote:error:默认情况下,更新非裸仓库中的当前分支
remote:error:is否则,因为它会使索引和工作树不一致
remote:错误:用你推送的内容,并且需要'git reset --hard'来匹配
remote:error:工作树到HEAD 。
remote:error:
remote:error:您可以在远程存储库中设置'receive.denyCurrentBranch'配置变量t
remote:error:'ignore'或'warn',以允许推送int
remote:错误:当前分支;然而,除非您
remote:error:安排它更新其工作树以匹配您在som
remote:error:其他方式中推送的内容,否则不建议这样做。
remote:error:
remote:error:为了压制这个信息并保持默认行为,se
remote:error:'receive.denyCurrentBranch'配置变量为'拒绝'。
有没有办法在笔记本电脑和远程服务器上获得工作副本?
谢谢
您可以设置该选项(在服务器上):
git config receive.denyCurrentBranch忽略
或者在服务器端使用两个存储库。一个是你推送到的裸仓库。另一个是非裸仓库,它是裸仓库的工作副本克隆。你将一个post-commit钩子放到你的工作副本中并执行一个 git pull
。<!c $ c> cd / p>
I have a remote web server that I have full access to (ssh, git, etc.). I want to be able to edit files on my computer and push them to the remote server. When I use a bare repository it doesn't change the file, but when I use a non-bare repository it complains with the following message:
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 t
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing int
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 som
remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, se
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
Is there any way to get working copies on both my laptop and the remote server?
Thanks
You can either set that option (on the server):
git config receive.denyCurrentBranch ignore
Or use two repositories on the server side. One is the bare repository that you push to. The other one is a non-bare repository which is a "working copy" clone of the bare repo. You give the bare repo a post-commit hook that cd
s into your working copy and executes a git pull
.
这篇关于Git远程存储库(包含文件?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!