title: git push results in permission denied or (branch is currently checked out)
body: <p>I have cloned a remote repository and made a few commits. I am trying to push my commits back to the repository so other developers can fetch them. First I tried: <code>git push "other_serv" my_branch:master</code> but I got</p>
  
  <pre><code>remote: error: refusing to update checked out branch: refs/heads/master[K
  remote: error: By default, updating the current branch in a non-bare repository[K
  remote: error: is denied, because it will make the index and work tree inconsistent[K
  remote: error: with what you pushed, and will require 'git reset --hard' to match[K
  remote: error: the work tree to HEAD.[K
  remote: error: [K
  remote: error: You can set 'receive.denyCurrentBranch' configuration variable to[K
  remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into[K
  remote: error: its current branch; however, this is not recommended unless you[K
  remote: error: arranged to update its work tree to match what you pushed in some[K
  remote: error: other way.[K
  remote: error: [K
  remote: error: To squelch this message and still keep the default behaviour, set[K  
  remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.[K
  To user@server:/path/to/git
  ! [remote rejected] my_branch -&gt; master (branch is currently checked out)
  </code></pre>
  
  <p>So I googled the problem and on the remote server tried:</p>
  
  <pre><code>git checkout -b dummy
  </code></pre>
  
  <p>Then tried to push again but got the same error. So instead of pushing to the master I tried to push to dummy. Then I got this error:</p>
  
  <pre><code>error: Unable to append to ./logs/refs/heads/dummy: Permission denied
  To user@server:/path/to/git
   ! [remote rejected] my_branch -&gt; dummy (failed to write)
  error: failed to push some refs to 'user@server:/path/to/git'
  </code></pre>
  
  <p>So I searched so more and found out some people had problems with their permissons. So I chmod'd and chown'd all the files:</p>
  
  <pre><code>-rw-rw-r-- 1 user git   41 2011-06-20 20:07 dummy
  -rw-rw-r-- 1 user git   41 2011-06-19 19:47 master
  </code></pre>
  
  <p>and I am able to write to both dummy and master, but I still get the error above. Anyone have any solutions? I've been banging my head at this supposedly simple problem.</p>
  
  <p><strong>EDIT</strong>:
  Seemed to have found the root cause. For some reason my repo is located at /path/to/repo.git even though all the commands I use point to /path/to/repo. Is this part of git?</p>
  
  <p><strong>EDIT 2:</strong>
  Turns out there was a second folder called ./repo.git. Since the ./repo folder was bare, git was searching ./repo.git for the ./repo files rather than ./repo. It seems when searching for ./.git, git prefers ./repo.git/.git over ./repo when the git config files are inside ./repo</p>