I accidently ran command git pull <wrong_remote_url>
in my repository. During the pull process, I cancel it by click Ctrl+C
.
$ du -h -d 1
20M . # At first the repository is only 20M
$ git status
OK
$ git pull https://example.com/large_repository.git # accidently pull the wrong repository
press Ctrl + C during the pull # cancel it during the pull, because I find it is downloading a lot of large file
$ git status
On branch master
nothing to commit, working directory clean
$ du -h -d 0
2.1G . # Now the repository is too large
$ du -h -d 0 .git
2.1G .git # There may be a lot of cached and useless file in .git directory
The repository still works, I can still use git as usual and the extra 2G
file will not be pushed to repository. But I know there is about 2G
cached file in the .git
directory. How can I delete these files? I tryied git gc
and git clean
, but they don't work. For some reason, there is some database data in the repository, so I don't want to delete the repository and clone it again.
I find the tmpfile in .git/objects/pack/
named as tmp_pack_9qTKaE
, tmp_pack_CKZSuG
, etc.
I think it is the large, useless cached file. It works if I delete them:
rm -f .git/objects/pack/tmp_*
Is there any command in git I can delete these file automatically and safely?