Monthly Archives: July 2016

Git failed to lock refs/head/branch

This one threw me off but here is how you would typically run into such a problem.  It is especially true if you are mostly using Git via command line.


  1. You have a remote branch located at feature/INT-4765-bad-things-predictor
  2. You are using git via command line.
  3. You are working on Windows.

So here is what you do:

  1. You check out the repository by typing
  2. git checkout feature/int-4765-bad-things-predictor.
  3. You make some changes to this new local repository.
  4. Then you run a the git add and commit commands to stage the changes readying them to be pushed to the remote.
  5. Then you attempt to push the changes and you are welcomed with an error which resembles this:

remote: error: failed to lock refs/heads/feature/int-4765-bad-things-predictor  To http://knji@stash.pidac.corp:7990/scm/int/home-reno-mentor.git
! [remote rejected] feature/int-4765-bad-things-predictor -> feature/ INT-4765-bad-things-predictor
error: failed to push some refs to ‘http://knji@stash.pidac.corp:7990/scm/int/home-reno-mentor.git’

This error does not say much but thanks to Google, the first link presented if you search for “git failed to lock ref” is this  StackOverflow listing. Basically this is an overly convoluted (if you will) message just to tell me remote repository cannot be found.

The problem here lies with Git on Windows’ case sensitivity.  A branch named feature/INT-4765-bad-things-predictor with Git implementation on Windows is apparently not the same as feature/int-4765-bad-things-predictor.  Hint: case sensitivity.

To fix this problem, I did two things:

  1. Navigated to the actual branch path on my local machine and capitalized the name to match that on the remote box.
  2. Re-ran git checkout with the branch name, exactly as it appears on remote, respecting case such as  git checkout   feature/ INT-4765-bad-things-predictor
  3. This should resolve this issue and allow you to push your changes to the remote.


Happy Coding.