Question

I have made a bunch of changes on my local git version of a Rails project that I don't want to lose, however in doing so, I accidentally created a vendor/bundle folder in Git.

I realized as soon as I committed that I did this and did a git rm for the folder (and added the folder to gitignore), and committed again. However, now I can't push the original because the bundle is too large.

What I need

  • How can I keep the edits (and new files) I made.
  • While removing the bundle folder from git history
  • And not pushing that commit with them since the directory is too large

I've been searching SO for various ways of soft resetting here, but I'm stuck..

Was it helpful?

Solution

You could do git reset --soft HEAD~x where x is the number of review you want to reset - 2 in your case and then add the directory to the gitignore file and also remove it from the staged area.

OTHER TIPS

I think I found the answer:

This occurs fairly commonly. Someone accidentally commits a huge binary file with a thoughtless git add ., and you want to remove it everywhere. Perhaps you accidentally committed a file that contained a password, and you want to make your project open source. filter-branch is the tool you probably want to use to scrub your entire history. To remove a file named passwords.txt from your entire history, you can use the --tree-filter option to filter-branch:

Source:

git filter-branch --tree-filter 'rm -f /vendor/bundle' HEAD

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top