tags:

views:

129

answers:

3

I accidentally committed my development.sqlite3 file to Git, and it seems to be slowing down my commits. I know about .gitignore, but does this take the file out of my repository once I've done so? My concern is is with reducing the commit and push times.

A: 

No. All the .gitignore file does is tell the various Git user interface tools to ignore that file when batch-committing changes. You can still manually put any individual file you want into Git's database, and adding entires there will not remove anything from the Git revision database.

T.E.D.
You haven't actually answered the real question, which is how to get rid of the file.
Jefromi
+1  A: 

Try this:

  git filter-branch --tree-filter ´rm filename´ HEAD
Derick
`filter-branch` is definitely, definitely overkill. The file in question was only added in one commit and has not been modified since.
Jefromi
+3  A: 

There's no need for fanciness with filter-branch - this is just in one recent commit. If not, simply remove the file (git rm --cached <filename>) and amend your commit (git commit --amend). The --cached option tells git to only remove the copy in the index (the commit staging area), and leave the version in the work tree intact.

If it's farther back in the history, you can use interactive rebase (git rebase -i <commit before the bad one> master), choose to edit the bad commit, and rm/amend as before. Be sure to add it to your gitignore as well, of course.

Note that if you've already pushed this commit, you'll have to use push -f to get the non-fast-forward to push, and if anyone else has pulled it already, they'll be annoyed (see the "recovering from upstream rebase" section in the man page of git-rebase.

Jefromi
I'm curious why this answer was downvoted - anyone care to tell me how it could be improved?
Jefromi