46

I got this message when i tried to create repository by using Git clone.

git did not exit cleanly (exit code 1)

How to fix this?

CodeWizard
  • 128,036
  • 21
  • 144
  • 167
Nevaeh
  • 1,519
  • 7
  • 24
  • 45
  • 1
    may be msysgit problem! – user3283976 Mar 04 '14 at 14:05
  • Please provde more info. Do you use SSH? What version of msysgit and TortoiseGit are you using? – linquize Mar 17 '14 at 13:08
  • try to `git clone` using the command line. Maybe TortoiseGit chokes some important error messages. If so, throw away TortoiseGit and use the command line instead (http://stackoverflow.com/a/21188318/520162) – eckes Mar 17 '14 at 14:30
  • 1
    Post more information, otherwise nobody will be able to help you. – eckes Mar 17 '14 at 18:24
  • I had this issue when authentication would not succeed for my TFS-Git repo. I had to modify some settings on my account login as described here in detail: http://www.allenconway.net/2014/10/fixing-authentication-failed-message.html – atconway Oct 20 '14 at 14:02
  • Side note really suited for Meta: why can't I use the "duplicate of" flag multiple times? If all duplicate flags have to be done in one go, the interface should say so. This is a duplicate of the following three: http://stackoverflow.com/questions/9617336/how-to-resolve-git-did-not-exit-cleanly-exit-code-128-error-on-tortoisegit http://stackoverflow.com/questions/14848263/tortoisegit-trouble-git-did-not-exit-cleanly-exit-code-128 http://stackoverflow.com/questions/29428009/git-did-not-exit-cleanly-exit-code-128 --all of which have low quality answers :( – Alex Hall Mar 25 '16 at 20:35

23 Answers23

33

Try these two commands in git bash:

1) git gc --force

2) git fetch -p

Suresh Karia
  • 17,550
  • 18
  • 67
  • 85
Sahadevan
  • 331
  • 3
  • 2
9

Right-click folder -> TortiseGit -> push-> choose unknown changes 》

sandip
  • 533
  • 9
  • 29
陈先生
  • 91
  • 1
  • 2
8

Right from my experience, I most often get this when I have locally changed files that will be over ridden by the pull, you need to stash or move the files before you can pull it.

RenScorch
  • 81
  • 1
  • 2
6

Sometimes it happens because of incomplete of some operations such as "stash save". It creates an index.lock file in the .git folder and that causes this error. What you need to do is going in to the .git folder and delete index.lock file and restart what you wanted to do.

The .git Folder

The index.lock File

Syed Mobarak
  • 69
  • 1
  • 2
4
  1. Right-click > Revert > Select All
  2. Click OK;
  3. After Revert process is finished, PULL.

Problem solved!

Patrick
  • 5,526
  • 14
  • 64
  • 101
3
Right click -> TortoiseGit -> Settings -> Network
SSH client was pointing to C:\Program Files\TortoiseGit\bin\TortoisePlink.exe
Changed path to C:\Program Files (x86)\Git\bin\ssh.exe
eric more
  • 64
  • 3
3
  • Go to the project folder.
  • open .git folder .git=>refs=>remotes=> Delete the origin folder

Finally do pull/Push. It will work.

Rachid K.
  • 4,490
  • 3
  • 11
  • 30
2

Actually, this error message just says that there is some problem but no specifications of the problem. So, in my case, it was a pending pull request. I pulled the changes into my repo, and then pushed it again and it worked. Moreover, if there is an error on tortoisegit, I prefer to do the same on console. Console gives more detail error message

user3050590
  • 1,656
  • 4
  • 21
  • 40
1

Following this guide I had the same issue. To expand on Eric Moore's ridiculously vague answer,

Right click > TortoiseGit > Settings > Network

Down the bottom in the "SSH" section, hit Browse and find your TortoiseGit\bin\TortoisePlink.exe file. In my case the path was under Programs as opposed to Program Files

Abraham Brookes
  • 1,720
  • 1
  • 17
  • 32
1

I was heard that, one of the reasons is , the project is too large, so increasing the post buffer could solve the problem. so open the editSystemWideGitConfig, and add the following statements under [http] , postBuffer = 524288000. maybe work.

lynn
  • 11
  • 1
  • 2
    Right-click folder -> TortiseGit -> Settings -> Git , "edit System Wide Git COnfig", – lynn Oct 10 '16 at 03:57
1

For me it was due to insufficient disk space , and it was resolved after I freed up some disk space on my local drive.

Reza Iranpour
  • 181
  • 1
  • 5
0

Actually, the easiest way to determine the error is to use 'Git Sync ...' then perform a pull/push from there - the error message is far more meaningful (i.e. there is one) and at least in my case, my -1 was due to a network path issue

schlock
  • 519
  • 3
  • 5
  • 14
0

I ran into the same issue after upgrading Git. Turns out I switched from 32-bit to 64-bit Git and I didn't realize it. TortoiseGit was still looking for "C:\Program Files (x86)\Git\bin", which didn't exist. Right-click the folder, go to Tortoise Git > Settings > General and update the Git.exe path.

Michael Flanakin
  • 472
  • 1
  • 5
  • 18
0

This is Just because you have made changes on your remote repository which was not pulled on your local repository.

To resolve simply 1. Pull from remote repository to local repository. It will not undo any changes locally. It will just update local repository. 2. Now push the changes to remote repository. It will work

Abhishek Maurya
  • 321
  • 1
  • 3
  • 13
0

For My case i did 3 steps to achieve the sucessful build.

  1. revert all the local changes if any (or just keep a copy of it in case you need it for future use)

  2. Do a git clean up, do a pull and check the logs for error

  3. GO to the git bash option and the error i was getting in log in above stem (i my case ) as "error: cannot lock ref and the branch details", so in the git bash i ran the following command git update-ref -d 'Branch_name'

For example if the error was something like **

  • ISSUE

**error: cannot lock ref 'refs/remotes/origin/EXMPLEISSUE/EXAMPLE-1011_DEMO_web_interface_DOES_NOT_GET_GIT_UPDATE':

Then i ran following command git update-ref -d 'refs/remotes/origin/EXMPLEISSUE/EXAMPLE-1011_DEMO_web_interface_DOES_NOT_GET_GIT_UPDATE'

We have to ensure all the error in logs to be solved similarly before getting a successful pull by doing git update-ref -d 'Branch_name' and finally i can get the take the successful pull from git.

0

My Git account started having problems right after I changed my email address (my work email changed). I tried everything I could, uninstalling, reinstalling, spending time on the phone with git helpdesk, etc.

Gave up and created a new email address and new account, but still kept getting 'did not exit cleanly' message.

How I resolved was: uninstall everything git related, remove all references to anything git including tortoise under appdata, delete all git folders under Program Files and Program Files (x86), remove Window Credentials (Credential Manager in Control Panel) for all things git, reboot, reinstall with new account.

LionDog823
  • 16
  • 2
0

first login on git then before push take the pull. issue will be resolved

Saurabh
  • 472
  • 6
  • 6
0

I have faced this situation and in my case, I was using two git id's simultaneously. so what it does it will update the credentials in the credential Manager

Control Panel\User Accounts\Credential Manager

as shown here

inside Credential Manager, you will find the git hub credentials inside the Generic credentials there you have to update your git credentials.

marcolz
  • 2,880
  • 2
  • 23
  • 28
0

I also encountered this error message due to longpath issues. Try to input this, that's helpful for me.

git config --global core.longpaths true

Mystic Lin
  • 365
  • 4
  • 15
0

I removed the repo and then recloned it. Then the problem is solved. Ensure your unpushed files are well backed up before you do so though.

0

Just check your branch name in remote and local hope there may be a case-related miss-match .

-1

Right-click folder -> TortiseGit -> Clean up.. -> click OK

None of the above solutions worked for me but this one did.

tyrol37
  • 15
  • 1
-1

to work just use force during push

Ariful
  • 13
  • 1
  • 1
  • 5