'Failed to push some refs to' errors

If your error looks similar to this, then this is a match:

$ git push
To ssh:meirionconsulting.com:/var/cache/git/work.git
! [rejected] master → master (fetch first)
error: failed to push some refs to 'ssh:
imiell@meirionconsulting.com:/var/cache/git/work.git'\
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull …') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push –help' for details.

1) Gather facts

Examine the output of your error above and extract the key points of information:

Note down the repository mentioned in the To <repository> line in the output as the 'remote repository'.

Note down the two names either side of the in the line that begins ! [rejected] as 'fromref' and 'toref' respectively.

Run:

git remote -v | grep fetch

from within your repository. Find the line that matches your 'remote repository' and note the first word on the line as the 'remote repository reference'.

2) Examine differences

Make sure you have your remote branch 'fetched' locally ready for comparison.

TODO

3) Decide on resolution

TODO

'git pull'

'git pull --rebase'

You could leave a comment if you were logged in.