1

I have accidentally deleted my commits on pythonanywhere.com and now I see very old state of my files. My Django website isn't working at all.

What I did:

$ git reset --hard HEAD~1

And then:

$ git push --force

That was big mistake. I deleted commits from remote as well. What I wanted to do to fix it:

git reflog

And then use:

git reset --hard <sha value>

Unfortunately, bash console returned following error:

fatal: unable to write new index file

and then I have discovered that I am run out of space on my pythonanywhere account. It is strange, because before commits I had about 80% of used space, and now I have 100%. Is this the reason why I cannot use git reset command? I deleted single file to free up the space, but still it is telling me that space is 100% used. Now I see old version of my Django project, it never took up so much space.

What can I do to restore previous state of my files?

James Z
  • 12,209
  • 10
  • 24
  • 44
Percival
  • 21
  • 5

2 Answers2

2

First, as documented in pythonanywhere Disk Quota, check what is using up all your space:

du -hs /tmp ~/.[!.]* ~/* | sort -h

Try and clean up as many files as possible, before attempting your git reset --hard <sha value>.
For instance, try also, to gain space, to "clear my local working directory" (assuming your current files are not the ones you want):

git clean -ndf # remove the n to actually remove files

Please advise, if I can remove folder called local. I think this is something auto-generated but I don't have knowledge about it and why it is so heavy

The .local folder is not generated by Django itself.
It is a folder created by the pip package manager when installing packages with the --user flag.
It is used to store user-specific packages and configurations.

You can safely delete it if you don’t need the packages installed in it anymore.
However, if you are still using the packages installed in it, you should not delete it.

In your case: delete it in order to get some free space and make your commit, then re-create it with your project build process, which will trigger the re-installation of the missing dependencies.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thank you, could you please tell me what is "project build process"? Will this folder reappear by its own? Or do I need to do something to restore it? – Percival Mar 25 '23 at 15:07
  • @Percival That would be the "[pythonanywhere Django deployment process](https://help.pythonanywhere.com/pages/DeployExistingDjangoProject/)", which should (not tested personnaly) restore all dependencies based on your Django application code (ie, your current code) – VonC Mar 25 '23 at 19:11
  • I deleted local folder and still I have 100% storage used. I don't know what is going on. When I try to make new commit, I see message "no changes added to commit". When viewing git log, I see only two old commits, I don't see the commit which I reverted. Despite that, I have proper state of files, but I don't know to which commit that state belong to. I see communicate "HEAD detached at" which refers to old commit SHA, which seems to not be present at git log. I'm so confused. – Percival Mar 25 '23 at 21:26
  • @Percival Did you retry the `du -hs` command, to check where the space is used? – VonC Mar 25 '23 at 21:27
  • Yes, It shows that the main folder of project takes 437M (out of 512). It consists of different folders which represents pages of website: contacts, projects etc. Unfortunatelly even if I am inside this main folder, command does not show what is taking so much space. It shows usage inside high level folder only, not inside nested main one. – Percival Mar 25 '23 at 21:53
  • @Percival Can you repeat that command inside the high level folder in order to drill it down? (and repeat it after that in the next biggest subfolder, and so on) – VonC Mar 25 '23 at 21:56
0

I managed to reset to the previous commit and restored proper state of files, but still pythonanywhere is saying that I am using 100% of storage.

I did:

du -hs /tmp ~/.[!.]* ~/* | sort -h

And I found that the folder .local/ takes the most of space. Inside it, I see bin and lib folders with python3.6 folder and other Python-related stuff, but I don't know if I need this - I don't remember if that was present before reset.

Please advise, if I can remove folder called local. I think this is something auto-generated but I don't have knowledge about it and why it is so heavy. Is it commonly used in Django and needed?

I am unable to make new commit because when I am doing git add *, I see an error: fatal: error when closing sha1 file: Disk quota exceeded

Percival
  • 21
  • 5