cannot push into git repository

前端 未结 7 814
既然无缘
既然无缘 2020-12-02 07:19

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:         


        
相关标签:
7条回答
  • 2020-12-02 07:38

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

    That is:

    git config receive.denyCurrentBranch updateInstead
    
    0 讨论(0)
  • 2020-12-02 07:38

    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.

    0 讨论(0)
  • 2020-12-02 07:39

    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

    0 讨论(0)
  • 2020-12-02 07:41

    Try below command:

    git config receive.denyCurrentBranch warn
    
    0 讨论(0)
  • 2020-12-02 07:48

    At server side, do this:

    git config receive.denyCurrentBranch ignore
    

    Then you can push at local.

    0 讨论(0)
  • 2020-12-02 07:53

    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

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