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!
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.
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.
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>.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With