0

I added a dmg file to my project, containing all my songs in it. It was over the 100MB GitHub limit. So when I tried to push it, it wouldn't do anything. But it still recognized that it was there even after I deleted it. I tried making a copy out of it but now Atom will crash when I open the project in Atom (GitHubs text editor)

Jake Symons
  • 468
  • 2
  • 10
  • 19

2 Answers2

0

You can revert to the previous commit by using git reset --hard <commit_hash>

Find the <commit_hash> by using git log and taking the long string of numbers and letters after commit. It'll look something like this:

commit 53f6a9b4219e200a6a0dcf8d367844c1f75e3517 <- this long string is what you want (not the "commit" part though)
Author: author <email@email.com>
Date:   Thu May 17 16:10:39 2018 +0800

    Commit message.
rst-2cv
  • 1,130
  • 1
  • 15
  • 31
  • Thanks! This seems like it would work but im getting a 'parse error near \n' even though I did not press enter – Maya May 30 '18 at 01:21
0

As has already been adviced before by @ResetACK, you could reset to the previous commit, but you could also amend the commit where you added the file if there are other changes on that commit that you would like to keep. Assuming that the last revision on your current branch is the revision where you added the file, you would do this:

git rm --cached mi-dmg-file.dmg
git commit --amend --no-edit

If it is not the latest revision on the branch, it can be done this way:

git checkout <the-revision-id> # checkout to the revision where we want to remove the file
git rm --cached mi-dmg-file.dmg
git commit --amend --no-edit # at this point, we diverged
git cherry-pick <the-revision-id>..the-branch #cherrypick from original revision to the tip of the branch
git branch -f the-branch # set the branch pointer to this revision now
git push *blahblah arguments* # at this point we can push the branch

And now you should be able to push fine.

eftshift0
  • 26,375
  • 3
  • 36
  • 60