I am just starting out with GIT (i\'m coming from cvs) and would like to set up something akin to cvs/svn with Git. I performed the following steps:
cd o:/r
For the first push you'll need something like
git push origin master
See also the push.default option option.
In any case, if you're later going to run into a problem of pushing to a non-bare repository, so you'll need to read about that too.
As the error message states, the branch you're trying to push to (master) is checked out in the origin repository. You could solve this by going to o:/repository and checking out a different branch.
If you still want to push to a checked out branch of a remote non-bare repo, it is now possible (Git 2.3.0, February 2015), provided there is no modified files in the target working tree.
In that remote repo, do:
git config receive.denyCurrentBranch=updateInstead
It is more secure than config receive.denyCurrentBranch=ignore: it will allow the push only if you are not overriding modification in progress.
See commit 1404bcb by Johannes Schindelin (dscho):
receive-pack: add another option forreceive.denyCurrentBranchWhen 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.
This happened to us a few weeks ago. It means that you have a working directory checked out in your origin repository and you cannot push to overwrite.
at the origin you need to bare the repository. I don't know of a way to do it with one command. What I did (at the origin repository)
> mv repository repository.old
> git clone --bare repository.old repository
I see that the origin in your case is the o:/repository. The origin, should not be a checked out working copy, so you can init a bare repository or copy as per above. To get the scenario you described to pass:
cd o:/repository
git init --bare
cd <working directory>
git clone o:/repository
git push origin master
this should work just fine for you:
good reading: http://www.gitready.com/advanced/2009/02/01/push-to-only-bare-repositories.html