This is what I have done so far and I will say this procedure worked on Ubuntu 9.10 which perhaps had a different version of git.
server: mkdir ~/git
local:
Pushing to a non-bare repo is now possible (Git 2.3.0 February 2015).
And it is possible when you are pushing the branch currently checked out at the remote repo!
See commit 1404bcb by Johannes Schindelin (dscho):
receive-pack
: add another option forreceive.denyCurrentBranch
When synchronizing between working directories, it can be handy to update the current branch via '
push
' rather than 'pull
', e.g. when pushing a fix from inside a VM, or when pushing a fix made on a user's machine (where the developer is not at liberty to install an ssh daemon let alone know the user's password).The common workaround – pushing into a temporary branch and then merging on the other machine – is no longer necessary with this patch.
The new option is:
updateInstead
Update the working tree accordingly, but refuse to do so if there are any uncommitted changes.
That is:
git config receive.denyCurrentBranch updateInstead
As I pointed out in this post heroku-like git setup? pushing to working repositories is a bit dangerous as any work in progress is not taken into account by the push, and it is quite easy to subsequently lose any uncommitted changes (basically the working HEAD can get out of step with the working branch HEAD). Git now has a warning to inform you of this - the, gory, details are in the following link:
git push to a non-bare repository
It is recommended that your published repository should be a bare repo which does not have a checked out tree. Bare repos are created using the "git clone --bare" option.
Both of client and server side
d:\Repositories\repo.git>git config receive.denyCurrentBranch updateInstead
Didn't work for me.Both of client and server's version are 2.16.2.windows.1
I added this to \\File-server\projectFolder\.git\config
[receive]
denyCurrentBranch = updateInstead
This works for windows.Don't need init --bare
Try below command:
git config receive.denyCurrentBranch warn
At server side, do this:
git config receive.denyCurrentBranch ignore
Then you can push at local.
VonC answer was helpful but it took me some time to realize that for Windows the command would be the following without the equals.
d:\Repositories\repo.git>git config receive.denyCurrentBranch updateInstead
My version is Git for Windows v2.11.1