Added a large file to a git branch, committed changes, now the file is in every branch (including master)
I'm at a point where I realized I took some actions that were the equivalent of entering a cave without a flashlight. Hopefully this retelling of events will contain an indication of what went wrong.
I began at my project's master branch. I performed a git pull from the remote master (to make sure I had the most recent build), then a git checkout -b newFeature. With this newFeature branch, I made some changes, including adding a 700mb .mp4 file. I then committed my changes with git commit -a -m "New features and a big mp4 file..." I never pushed the changes to the remote. Made some more changes, decided I didn't want them, so I did a git stash at the end of the day.
This morning, I switched to master branch, where I did a git/status. I noticed my local master branch was now ahead of the remote master, which was odd because they should have been exactly the same. I also noticed that when I built my iOS app (from master, NOT newFeature) that the app size was 700mb bigger than it should have been.
Now this part is where I started panicking, so I apologize if the order of events is not completely accurate...
- I saw that my .mp4 file was an unstaged file after running git status.
- I tried to do a git reset HEAD <file>, which seemed to remove the file, but it still showed up in my builds.
- I then tried git rebase, but never got through it because I seemed to hit a loop where all git rebase --continue did was end up at the same place over and over, so I aborted (I've never done a rebase before).
- Giving up, I deleted all of my local files (or at least I think I did), restarted my computer (you never know), cloned everything from GitHub... and my builds are still including the large mp4 file.
I cannot seem to find the mp4 file, though it is clearly there when I build the app. I never pushed it to the remote, not that it would have let me anyway due to GitHub's restraints.
Any solutions, bread crumbs, or whatever would be greatly appreciated!! Thanks!
EDIT: I attempted to go back to the build before I ever made the newFeature branch using git reset --hard , still no luck, as my project will still build with the mp4 file.
Perhaps I could find where this mp4 file is store locally? I can not find it in my project folder.
SOLVED: See my answer below... long story short, I needed to Clean my build in Xcode (Cmd-shift-K) to remove the MP4 from the build folder.
Try git clean to remove any extra files. You should also check the logs of your build system to find out where this file is getting included.
Of course it's something I should have done right from the get-go. I've read before, "Before building your project, do a Clean on your build" (Cmd-Shift-K in Xcode). After running a disk report on my drive (using JDiskReport), I found the mp4 file cached in Xcode's DerivedData folder in my Library folder. Doing a Clean on the build removed the file from this folder, and no other future builds included it.
I guess I never ran across a time when not performing a Clean was really evident. When I was restarting Xcode, I wrongly assumed any sort of cache clearing would be done then.
So turns out this wasn't a problem with git directly, but with Xcode. I'm not sure if it should be the correct behavior or not, but I will now be run a Clean whenever switching between branches.