开发者

dropbox+git: can't push back to origin

I have a bare repository in a Dropbox folder which I share across multiple computers I use. This should be a simple setup but I can't seem to push back my changes.

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 inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error:
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
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 some
remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To /path/to/project.git/
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to '/path/to/project.git/'

I tried to pull, but it does nothing.

$ git pull
Already up-to-date.

Branches sample:

$ git branch -a
  asdf
* master
  remotes/origin/HEAD -> origin/master

Status:

$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 2 commits.
#
nothing to commit (working directory clean)

The config:

$ cat .git/config
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates开发者_如何学编程 = true
[remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = /path/to/project.git
[branch "master"]
        remote = origin
        merge = refs/heads/master

What am I missing?


Try actually reading the error messages Git gives you:

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 inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.

In general, you usually only want to push to bare repositories. It appears that your dropbox repository is not actually a bare repository, because it has a checked-out branch.

Check /path/to/project.git/config and see what the configuration is there. If it's bare, it should have bare = true.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜