-1

I have about five local commits. But in the first commit I added big file, about 150MB. When I push to github I get error about big file.

I have tried to delete this file in the last commit, but it doesnt't work. I thought that git may be understand it, but it isn't.

How can I delete this file from commit or delete the first commit entirely if it easy?

user348173
  • 8,818
  • 18
  • 66
  • 102

3 Answers3

2

'Interactive rebase' part of the answer in

How to remove/delete a large file from commit history in Git repository?

should help you.

The 'git lola' command there is an alias for 'git log --graph --decorate --pretty=oneline --abbrev-commit --all --date=local'

Community
  • 1
  • 1
J.J. Hakala
  • 6,136
  • 6
  • 27
  • 61
  • Not sure of the `lola` command's relevance, but you should provide an example of how to rebase in case that link goes away. – scrowler Jan 13 '16 at 04:10
  • I linked to a stackoverflow answer hoping that it would remain available (practically) indefinitely. Is there some kind of expiration for old answers? – J.J. Hakala Jan 13 '16 at 04:25
  • I didn't check the target- no worries :-) – scrowler Jan 13 '16 at 06:15
1

You can reset the head and then unstage the 150 mb file and delete, and commit again like this:

  • 1st - git reset --soft HEAD~1
  • 2nd - git reset -q HEAD -- <FILE>
  • 3rd - delete file
  • So now just add and commit other files
Joel R Michaliszen
  • 4,164
  • 1
  • 21
  • 28
0

You can use git log to display commit history, and then use git reset SHA, where SHA is the first 7 characters of a previous commit, to put that as your most recent commit

1 - git log
2 - git reset SHA
Severage
  • 33
  • 1
  • 7