I had to run
git reset --soft HEAD^
to undo a commit with large files (
CodePudding user response:
Adding your files to .gitignore alone is not enough.
You should do this:
git update-index --assume-unchanged <file_path>
and add your files to .gitignore
If you want to do this to a directory, open that directory in your shell (using cd):
and execute this:
git update-index --assume-unchanged $(git ls-files | tr '\n' ' ')
CodePudding user response:
As chepner suggested in a comment, you probably really wanted a --mixed reset, not a --soft reset. However, as j6t added, you can recover from this error by using git rm --cached -rf .angular/cache (be sure to use the --cached to avoid removing the working tree copies).
You will still want to create or update your .gitignore so that you can't accidentally add the .angular/cache contents again. You should git add the file after updating it (or creating it with appropriate initial contents).
Had you used --mixed (or the default which is --mixed), you might have had to add some other files besides the .gitignore, but you could update the .gitignore file first, then use a standard "add everything" (git add .) to add everything except the current untracked-and-ignored files. This tends to be easier to get right, which is why it's the recommended method. But adding everything, then un-adding (git rm --cached -rf) the unwanted files, also works. It's just klunky and easy to get wrong.
