Select Page

Introduction

Git has vastly revolutionized the way code management can work, don’t you agree? It has indeed presented ideas that encourage better code tracking and revival on crash, as well as pushing code from repository to repository without needing to lift your hands up from the keyboard (as long as you’re not using a Git GUI Client).

Yes, my comrades. Using a Git client induces lack of productivity. It could make life a little easier with the friendly interfaces, but at times these very clients could end up getting worse. One of such cases includes this following error message reported by many users with the TortoiseGit Client:

git did not exit cleanly (exit code 1)

The solution to this, however, is not something that can easily be erased in a single given way. Users would usually face it based on their own situation and doing. Which is why in this article, I’ll try to include as much of the fixes as I possibly can. Don’t be afraid to try them all if you need to!


Delete the index.lock file

One of the most common reasons as to why the error message occurs is because of this file called index.lock, for which most people say that simply deleting the file helps them fix the error. But why in the first place is this one heck of a file causing the error and preventing any other git commands from running?

When you execute any git commands (be it from git bash or from a git client), git responsibly creates the index.lock file under the repository’s .git directory (which is hidden), in order to prevent any external source of git commands to create changes while the process is running. And once the process is over, git is supposed to automatically delete the index.lock file, or so it seems. 

You cannot always ensure that a git process was successful. If you try to terminate a running git command, it is quite probable that git didn’t get the chance to erase the index.lock file, and an initial index.lock file persists on your repository. Later on, when you try to execute some new commands, you’re no longer able to as git cannot create the index.lock file again now.

So the conclusion for this particular fix, is to simply remove the index.lock file which resides in the .git directory under your repository’s root folder. 


Reconfigure git client account

This is yet another common cause for the error message, which users might not even realize of. The problem is that the TortoiseGit client does not always print out the actual cause for the error, and only shows you the given error message, as compared to the barebones git (git bash). When you execute the same commands in a terminal, or in git bash, you’d usually be returned with the root of the problem. 

Anyways. What happens is that users unknowingly might try to execute certain commands which require you to first set up client information in order to be run, such for instance, the git push command. When you push code to a remote repository, git will want to keep track of the client who is making the push, and if you don’t have it set up, you’re probably not going to get past the error. So how do we fix this and set up the client information?

Trust me, it’s as easy as pie. First up, enter the Settings of the TortoiseGit client through the context menu on your Windows machine:

Inside the Settings window, click on Git:

You might encounter a confirmation window with some additional information. Simply click OK, and under the User Info, enter your credentials (Name and Email):

(Don’t end up giving a fake name and mail address like mine! It needs to be real. Very, very real)

Lastly, click on Apply on the bottom right to confirm the new changes in the settings.

And et voila! You should no longer be encountering the error the next time you try to execute the command which required your client information (given that this was actually the reason why you faced it).


Reinstall Tortoise git

In case nothing has helped you out to fix the error in the TortoiseGit client for git, your last resort might be to reinstall the client, and remove all the files that it might have created (including %appdata%). You might also need to remove your repositories while you do, and sometimes removing the repository alone (without uninstalling the whole client) may be enough to fix the issue. 

But this fix is probably not something you’d be happy to hear about, and I understand that very well. As long as you’re determined enough to get your job done, whatever it takes you to, you might not actually need to worry as there’s a better alternative, which folks call The Git Bash.


Use git bash

Yeah, yeah. I get it. It might not be as convenient as using a Git Client, given that most users are not used to terminals. But come on! You’re probably not using Git to track your homeworks, are you? So why be so shy to use a terminal for git commands? In fact, it is where most of git’s power truly shines. 

Enough baffling. Let’s get down to some real business now. Before you started using TortoiseGit, you’d probably have installed Git for Windows, which ships with an application called git bash. This application gives you a terminal interface to run git commands, as well as some basic shell commands that come with bash.

Here, you can pretty much run all the same commands you’d run on a Git Client like TortoiseGit. There may be some advanced features, which you’d barely ever need. The only big difference is that you need to do some typing to get the thing done, add a bit of commands vocabulary. But once you get used to it, you’d be riding the speed of thought (well, maybe a bit too exaggerated right there, but who cares).

I’d not be able to teach it all to you right here in this article. But there are enough good resources available online on how to use git bash. So go get your guts up, lazy comrades!