Skip to content

Refusing to update checked out branch #3

@jrean

Description

@jrean

Hi,

I bought your book (and just discovered it's now open source). Thank you for the awesome work!

Following your instruction I created a repository on my remote server.
After git init I created the post-receive hook file and added the following line:

#!/bin/bash
cd..
unset GIT_DIR

env -i git reset --hard
git checkout -f

I added the remote to my local git and performed a git push production master command to push...

Here is the output I received:

Counting objects: 781, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (720/720), done.
Writing objects: 100% (781/781), 32.39 MiB | 652.00 KiB/s, done.
Total 781 (delta 283), reused 0 (delta 0)
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 ssh://xxx/var/www/xxx/
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'ssh://xxx/var/www/xxx/'

Questions:

  • What's wrong?
  • I used to do the same kind of flow but instead using a git init --bare repository.
  • What's the difference between the two repository (as I have a hard time to clearly understand while googling)

Last but not least, I have your e-mail. I have some questions I would like to discuss with you. Can I send?

Thanks for your help.

Great job again.

J.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions