Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undo git commit in Rstudio that is too big to push

I am very new to github and am trying to incorporate it into my work for the first time. I am working in RStudo, using the commit and push buttons in the gui. I put some of my data in the folder on my computer that I am working out of. I made a few commits, then I commited that data, and then I made another few commits. Then I tried to push the whole thing to github. However, I got an error message saying:

remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.        
remote: error: Trace: f4a84c3a176d2c77039d041a21c0c455        
remote: error: See http://git.io/iEPt8g for more information.        
remote: error: File S_Fulltaxonomy.csv is 158.06 MB; this exceeds GitHub's file size limit of 100.00 MB        
To [email protected]:moanam/paper.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to '[email protected]:moanam/paper.git'

My branch is now ahead of origin/master by 10 commits, with the problem commit somewhere in the middle.

I have looked for solutions to this and have found posts like undo commit in middle of Git history, How to modify existing, unpushed commits? and How to remove a too large file in a commit when my branch is ahead of master by 5 commits

However, the solutions to this are a line of code where the original asker is supposed to substitute a few words and run it somewhere. I really am very new to this and have no idea where to run all this code, what to substitute and how to find and change the problem commit in my work. How do I do this? Or is there a gui based version of undoing the commit in RStudio? Or could someone please explain exactly how to use the code?

I know that this is probably a very simple question and I am sorry for wasting your time with it. However, I have genuinely spent quite a while looking already and can't find anything simple enough for me to work with! There is always too much knowledge assumed. Thanks for your help!

like image 510
thestral Avatar asked Oct 18 '16 18:10

thestral


People also ask

How do I undo a committed large file?

If the large file was added in the most recent commit, you can just run: git rm --cached <filename> to remove the large file, then. git commit --amend -C HEAD to edit the commit.

How do I revert a commit in git Rstudio?

If you have saved changes to your file(s) but not staged, committed or pushed these files to GitHub you can right click on the offending file in the Git pane and select 'Revert …'. This will roll back all of the changes you have made to the same state as your last commit.

How do I undo a hard commit?

When you want to revert to a past commit using git reset – – hard, add <SOME-COMMIT>. Then Git will: Make your present branch (typically master) back to point at <SOME-COMMIT>. Then it will make the files in the working tree and the index (“staging area”) the same as the versions committed in <SOME-COMMIT>.


1 Answers

There is an easier way.

I am not sure how to do it via Rstudio but you can do this instead.

Go to the command line --> navigate to the directory of your project

Once inside type:

git reset HEAD~

If you want to undo two commits type it twice.

This will undo the last commit but won't delete any files. Therefore files will all reappear in the staged menu. After that, re-commit without the large files then push again and all should be ok.

like image 147
Adam Waring Avatar answered Sep 24 '22 03:09

Adam Waring