I recently accidentally committed and pushed multiple large files to my git repository. After removing them, the .git folder on my server is sitting at about 32gb, and effecting my website performance. I have no unpushed changes to the live site. Am I able to simply delete this folder to free up that space again, and will git automatically recreate a new one without the references to those large files? I don't need any history or logs of past changes up to this point so I'm ok losing that information.
3 Answers
No, if your delete the .git folder you gonna break everything...
You must remove the file from your git history. There are a lot of tutorials to remove a file or sensitive data... Personally, I suggest :
https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository

- 64
- 1
- 4
To undo commits that you have pushed to a remote repository using Git, you can use the git revert or git reset commands. Here are the steps you can follow:
Open a terminal window and navigate to the local repository where you want to undo the commits.
Use git log to view the commit history and identify the commit that you want to undo. Make note of the commit's SHA value, which is a unique identifier for the commit.
To undo the changes made in a specific commit using git revert, use the following command:
git revert <commit-SHA>
For example, if you want to undo the changes made in the commit with SHA 123456, you can use the following command:
git revert 123456
This will create a new commit that undoes the changes made in the specified commit.
To undo multiple commits using git reset, use the following command:
git reset HEAD~<number-of-commits>
For example, if you want to undo the two most recent commits, you can use the following command:
git reset HEAD~2
This will move the branch pointer to that commit.

- 51
- 3