繁体   English   中英

使用GIT更新本地文件服务器上的文件

[英]Using GIT to update files on local fileserver

好的,所以我在计算机上安装了一个repo设置,我正在寻找使用它来将更新推送到文件服务器上的某个位置。 我使用以下内容进行克隆:

从计算机上的目录开始:

git init
git add .
git commit -m 'initial'
cd ../

然后克隆到文件服务器上

git clone -bare testdir fileserverip/testdir

这样可以克隆,但是如何使用GIT更新? 与我以前使用GIT的经验不同,我不希望通过SSH或其他任何方式进行连接,那么如何设置推送?

编辑:

按照Makis的答案修改设置后,我在git push上收到以下错误

james-macbook:test2 james$ git push
Counting objects: 6, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 506 bytes, done.
Total 4 (delta 1), reused 0 (delta 0)
Unpacking objects: 100% (4/4), done.
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'.
To xxxxxxxxxxxxxxxxxxx
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'xxxxxxxxxxxxxxxxxxx'
james-macbook:test2 james$ 

有人知道这是什么意思吗?

编辑:刚发现这个,认为这是我需要的。 http://tiredblogger.wordpress.com/2009/11/09/creating-local-git-repositories-yeah-its-that-simple/

谢谢

如果可以通过NFS或Samba挂载服务器目录,请轻松进行。 我会先在服务器上创建裸仓库。 然后在您的计算机上克隆空的存储库并添加内容。

在那之后,一切都正常工作(拉,推)。

听起来您正在尝试通过推送到git存储库来执行与部署网站的常见问题非常相似的操作,因此有关如何执行此操作的信息也应同样适用于这种情况。

http://toroid.org/ams/git-website-howto

该网页描述了如何建立一个裸存储库(上面列出的命令中的FYI具有-bare而不是--bare ,这可能是您遇到的一个问题),并使用接收后挂钩自动更新目录的内容。 接收后挂钩通过调用git checkout -f执行此操作,但是指定了显式的工作树(裸仓库没有工作树,因此通常该命令将失败)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM