Reputation: 4825
I'm a git
n00b. I'm using Visual Studio Git Source Control Provider.
I accidentally staged and committed a lot of temporary files that are generated and saved in the App_Data
folder of my Web Project.
Now my repo is stupidly massive after this the commit.
Since they were under source control, I don't think that deleting them and committing again would make much of a difference (though I still tried that, and certainly didn't work).
I am aware that in the future I can/should add App_Data
to the .gitingnore
, but now the damage is done. :(
Thanks for any help!
Upvotes: 0
Views: 397
Reputation: 13838
I understand you would like to remove the objects for good from the repository, not just make another commit which will hide them in the future.
Since it's just your local repository, most bad things associated with rewriting history do not apply here. But nevertheless, I'm afraid this kind of operation is too advanced for Visual Studio Git Source Control Provider and there is no way to accomplish this from the extension.
Using command line tools, you can do an interactive rebase, e.g. for 5 commits back: git rebase -i HEAD~5
. A text editor opens and shows you all commits in that range, allowing you to do various changes on them.
If the whole commit is bad, you would just delete the line and let it replay the rest.
If only a part of the commit should be removed, you would:
pick
command to edit
on the relevant linegit rm -r App_Data
git rebase --continue
to amend the commit you have stopped at with the changes and continue replaying the rest of commits since thatA git gc
might be useful to cleanup the database afterwards.
Upvotes: 1
Reputation: 116197
Let's assume that you have git command installed. Then you can fix it by simply killing your last commit:
git reset --hard HEAD~
You can also kill commit while still keeping all files as they were after this bad commit:
git reset --soft HEAD~
Upvotes: 1
Reputation: 5755
$ git rm -rf <the folder with the temporary files>
Or, find some sort of designation of the names of the files and $ git rm
based on that designation.
Upvotes: 1