Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You are seeing a Git safety feature. Git refuses to update the remote branch with your branch, because your branch's head commit is not a direct descendent of the current head commit of the branch that you are pushing to.</p> <p>If this were not the case, then two people pushing to the same repository at about the same time would not know that there was a new commit coming in at the same time and whoever pushed last would lose the work of the previous pusher without either of them realising this.</p> <p>If you know that you are the only person pushing and you want to push an amended commit or push a commit that winds back the branch, you can 'force' Git to update the remote branch by using the <code>-f</code> switch.</p> <pre><code>git push -f origin master </code></pre> <p>Even this may not work as Git allows remote repositories to refuse non-fastforward pushes at the far end by using the configuration variable <code>receive.denynonfastforwards</code>. If this is the case the rejection reason will look like this (note the 'remote rejected' part):</p> <pre><code> ! [remote rejected] master -&gt; master (non-fast forward) </code></pre> <p>To get around this, you either need to change the remote repository's configuration or as a dirty hack you can delete and recreate the branch thus:</p> <pre><code>git push origin :master git push origin master </code></pre> <p>In general the last parameter to <code>git push</code> uses the format <code>&lt;local_ref&gt;:&lt;remote_ref&gt;</code>, where <code>local_ref</code> is the name of the branch on the local repository and <code>remote_ref</code> is the name of the branch on the remote repository. This command pair uses two shorthands. <code>:master</code> has a null local_ref which means push a null branch to the remote side <code>master</code>, i.e. delete the remote branch. A branch name with no <code>:</code> means push the local branch with the given name to the remote branch with the same name. <code>master</code> in this situation is short for <code>master:master</code>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload