5

I added a 50mb file or so and did a git commit.

I starting doing a :

git push origin master

But mid-way I cancelled the operation.

  1. how can I remove this file from the repo even though I did a git commit (I added it to .gitignore now but its sort of late)
  2. how can I see if the file is in the master or not?

I don't want to wipe the entire commit as there are other files I want commited (and not lost).

Blankman
  • 248,432
  • 309
  • 736
  • 1,161

3 Answers3

2

Good that you cancelled it.

Remove the giant file.

git add -A
git commit --amend -C head
git push origin yourbranch

You should be fine.

Adam Dymitruk
  • 117,004
  • 25
  • 140
  • 137
0

Step one DO NOT PUSH If you have pushed, report back after doing something drastic.

Decision: Has this been the last commit you made?

Step two--lastcommit: git commit --amend

Step two--oldercommit: read and follow the man git-rebase page for the bit about splitting commits

Step three: read and follow the man git-filter-branch page for the bit about how to compress your .git directory. Not critical and it will happen automatically eventually.

Step four: Make a clone from you current repo to double-check that the large file is not sticking around. Verify by repo size and the absence of the file.

Step five: Push

Adam Dymitruk
  • 117,004
  • 25
  • 140
  • 137
Seth Robertson
  • 29,251
  • 6
  • 60
  • 53
-1

There's another very similar question here that describes a number of options:

Completely remove file from all Git repository commit history

The simplest solution would git's filter-branch command.

Community
  • 1
  • 1
joelittlejohn
  • 11,321
  • 2
  • 37
  • 52