pushing to a git repository does not work

前端 未结 4 745
予麋鹿
予麋鹿 2020-12-09 06:06

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         


        
相关标签:
4条回答
  • 2020-12-09 06:56

    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.

    0 讨论(0)
  • 2020-12-09 06:58

    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.

    0 讨论(0)
  • 2020-12-09 07:01

    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 for receive.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.

    0 讨论(0)
  • 2020-12-09 07:09

    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

    0 讨论(0)
提交回复
热议问题