Category Archives: Git

Git cleanup of already locked files

Taken from

If you have either manually or by accident “breaked” in the midst of a git add or git commit, most likely the lock file of the file you attempted to git add/commit still exists, preventing you from further action on that file. There’s an easy way to solve this.


L-MAC-DEYNON:my_project_dir deynon$ git add data/reports
fatal: Unable to create '/Users/deynon/Projects/dir_1/.git/index.lock': File exists.
If no other git process is currently running, this probably means agit process crashed in this repository earlier. Make sure no other gitprocess is running and remove the file manually to continue.


Delete the …/.git/index.lock file… and git reset…

L-MAC-DEYNON:test_and_target deynon$ rm /Users/deynon/Projects/dir_1/.git/index.lock
L-MAC-DEYNON:test_and_target deynon$ git reset

And you should be good!


Git mass delete by find

Oops. You transferred repositories. Or, by accident included all your compile and tmp files into your commit. There’s a cool solution. Of course, substitute “*.pyc” with whatever reg ex you need…

Found this on

First, git rm them
find . -name "*.pyc" -exec git rm -f {} \;

Then, add a .gitignore file in the root of your repo and enter a line:

to prevent them from being added automagically in the future without an -f