-2

I have done something like this:

1. git add .
2.git commit

thus commiting a video file of 200mb which i then tried to remove by deleting the video file and repeating step 1 and 2, but that did not helped either, then i tried googling which ended up with running these three commands

1.git add -u
2.git reset HEAD path/to/file
3.git commit

thus i am on 3rd commit, still unable to push as my video file is still somewhere in commit.. what should i do to get out of this mess !

vijay shanker
  • 2,517
  • 1
  • 24
  • 37
  • 1
    let me explain why I think it's a duplicate: If you already **has committed** the large video to his local 'working' repository, then your repo will remember it even if it's lated deleted. That's because the 'history' will hold it so you can always revert back. That's the point of versioning and commits.. Since one of the (non-squashed) commits contains the large-file-blob, you would be pushing out that 200mb, just to immediatelly mark it as deleted (since they are separate changes!). So, I think that in addition to '.gitignore''ing that file, he must also remove it from history completely. – quetzalcoatl Feb 28 '14 at 08:47

1 Answers1

2

Adding new commits with the video file deleted does not help, as the big file will remain part of the repo. Instead:

git reset <commit>

Where commit is the one before adding the video file. Then

echo <video-file-name> >> .gitignore
git add .
git commit

The .gitignore file contains a list of files to be totally ignored by git.

SzG
  • 12,333
  • 4
  • 28
  • 41
  • Hm.. will jumping out of the huge-commit really prevent it from being sent during push? I'm not sure about that:/ surely, the "wrong-commit" will still be in the local repo and the huge file will still stick in the history. It might be reasonable to really-remove the file/commit as shown in the question I've linked to in the comments. – quetzalcoatl Feb 28 '14 at 08:50
  • 1
    After the reset the big video blob and the referring commit will still be in the repo, but they will be invisible, as no ref is pointing to them. They won't be pushed either. A subsequent `git gc` will remove them completely. – SzG Feb 28 '14 at 08:53