tcpiper
tcpiper

Reputation: 2544

how to set up a sychronous directory in remote server with git?

I have several windows computers as develop environment c:\projects\pyj and one ubuntu server /root/pyj as deploy one. Neither Github nor bitbuckets is my choice because I want to build git on my own server.

With the help of windows software I can synchronous pyj among windows computers. But how should I synchronous pyj between each window computer and server?

I already successfully set up ssh keys both in windows and my server, and I use git init --bare to create a remote respository. When I git push -u origin -all in windows, there aren't any source files push to server. This is not what I want.

So I remove origin and create another remote repo pyj and try git init in server, but encounter this:

$ git remote add pyj [email protected]:/root/pyj/.git/
$ git push -u pyj --all
Counting objects: 18, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (16/16), done.
Writing objects: 100% (18/18), 4.43 KiB | 0 bytes/s, done.
Total 18 (delta 0), reused 0 (delta 0)
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 inconsist                        ent
remote: error: with what you pushed, and will require 'git reset --hard' to matc                        h
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'.
To [email protected]:/root/pyj/.git/
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to '[email protected]:/root/pyj/.git/'

So, how should I use git to meet my need?

Upvotes: 0

Views: 77

Answers (1)

gzh
gzh

Reputation: 3616

After v2.3.0, git added the function of "push to deploy".

In remote side.

git config --get receive.denyCurrentBranch
git config receive.denyCurrentBranch updateInstead
git config --get receive.denyCurrentBranch

By this setting, when you push on client side, the remote worktree will be updated.

For details, please refer to releasenote of v2.3.0

Upvotes: 2

Related Questions