Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save duttashi/1011d1b52e3cc288df402807c1b20521 to your computer and use it in GitHub Desktop.
Save duttashi/1011d1b52e3cc288df402807c1b20521 to your computer and use it in GitHub Desktop.

Problem statement

Did some data analysis which resulted in generating a huge data file, greater than 100 MB. Accidentaly, tried to push it to Github and the nightmares began! Keep getting error messages, cant push because large files detected.

Solution

The following solution worked for me;

  1. Open command shell in the repo
  2. type, git status
  3. After this, you should see something along the lines of

`On branch master Your branch is ahead of 'origin/master' by 2 commits. (use "git push" to publish your local commits)

nothing to commit, working tree clean`

The important part is the "2 commits"! From here, go ahead and type in:

git reset HEAD~<HOWEVER MANY COMMITS YOU WERE BEHIND>

So, for the example above, one would type:

git reset HEAD~2

After you typed that, your "git status" should say:

On branch master Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

Now, you can push the commit again. Yay.

@titisawadogo
Copy link

Worked like a charm, Thanks

@hamnajaku
Copy link

Thank you! worked perfectly fine for me.

@baaixw
Copy link

baaixw commented Jan 8, 2024

It worked for me, thanks !!!

@gillesretiere
Copy link

gillesretiere commented Feb 6, 2024

Worked okay thanks !!!

@alice-ang
Copy link

Worked for me as well, thank you!

@asif03338826476
Copy link

Great!! KUdos

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment