好的,所以我的机器上有一个repo设置,我希望用它来将更新推送到文件服务器上的某个位置。我使用以下内容进行克隆:
从机器上的dir开始:
git init
git add .
git commit -m 'initial'
cd ../
然后克隆到fileserver
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/由于
答案 0 :(得分:1)
如果你可以通过NFS或Samba挂载服务器目录,那就很容易了。我会先在服务器上创建裸存储库。然后克隆机器上的空存储库并添加内容。
之后,一切都正常(拉,推)。
答案 1 :(得分:0)
听起来你正试图做一些非常类似于通过推送到git存储库来部署网站的常见问题,所以有关如何做到这一点的信息应该同样适用于这种情况。
http://toroid.org/ams/git-website-howto
该网页描述了设置裸存储库(上面列出的命令中的FYI -bare
而不是--bare
,这可能是您遇到的一个问题)并使用post-receive hook来自动更新目录的内容。 post-receive钩子通过调用git checkout -f
来执行此操作,但是指定了显式工作树(裸存储库没有工作树,所以通常命令会失败)。