开发者

Using GIT to update files on local fileserver

OK so I have a repo setup on my machine and I'm looking to use this to push updates to a location on a fileserver. I used the following to clone:

Starting in dir on machine:

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

Then cloning onto fileserver

git clone -bare testdir fileserverip/testdir

This clones fine but how can I use GIT to update? Unlike my previous experience with GIT I'm not looking to connect over SSH or anything so how can I set up the push?

EDIT:

After modifying my setup as mentioned in the answer by Makis I get the following errors on 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$ 

Anyone know what this means?

EDIT: Just found this, think it's what I need. http://tiredblogger.wordpress.com/2009/11/09/creating-local-git-repositories-yeah-its-that-simple/

Thanks


If you can mount the server directory via NFS or Samba, easy peasy. I would have created the bare repository on the server first. Then clone the empty repository on your machine and add the stuff.

After that, everything works like normal (pull, push).


It sounds like you are attempting to do something very similar to the common question of deploying a website by pushing to a git repository so information on how to do that should equally apply to this situation.

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

That webpage describes setting up a bare repository (FYI in the command you listed above you had -bare instead of --bare which could be one problem you are encountering) and using a post-receive hook to update the contents of a directory automatically. The post-receive hook does this by calling git checkout -f but with an explicit work tree specified (bare repositories don't have work trees so normally that command would fail).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜