Reputation: 21302
I tried and failed to push some large csv files to githib with a message telling me the file was too large.
So, I used git rm --cached file.csv
to delete them and then tried to push again.
However, the push looks like it is trying to push the same large file that failed like before. I suspect that the large file is still present in some form and I want to remove it from git so that I can just push the code files.
Here's what I see in my terminal after trying the above. It takes a while to push, couple of minutes, when it should presumably take a couple of seconds or less, given there's nothing to push (at least that was my understanding, so I'm confused why it looks and behaves like it did when I initially tried to push the large csv files).
git status
3 files changed, 1814376 deletions(-)
delete mode 100644 resources.csv
delete mode 100644 sample_submission.csv
delete mode 100644 train.csv
Macs-MacBook:donors_choose macuser$ git status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
.DS_Store
.Rproj.user/
donors_choose.Rproj
resources.csv.zip
sample_submission.csv.zip
test.csv.zip
train.csv.zip
nothing added to commit but untracked files present (use "git add" to track)
Macs-MacBook:donors_choose macuser$ git push -u origin master
Counting objects: 17, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (15/15), done.
Writing objects: 100% (17/17), 389.52 MiB | 4.59 MiB/s, done.
Total 17 (delta 2), reused 0 (delta 0)
There's a README in the directory and right now all I want to do is add it to my new repo in a "hello world" sense.
The terminal is currently showing the above code ending Total 17 (delta 2), reused 0 (delta 0)
however the terminal window is unresponsive and nothing shows in the repo on github.
EDIT After being un responsive for a few minutes the terminal window returned this message:
To https://github.com/myusername/myrepo.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'https://github.com/myusername/myrepo.git'
Upvotes: 2
Views: 1139
Reputation: 522732
This answers assumes that you fairly recently added that large file into your history, and, that you haven't been able to successfully push any of the commits which contain that large file.
The problem you are facing is that, even after you delete the large file and recommit, the file is still present in your history. When you go to push, that file will be included, and the hook will reject your push.
Perhaps the simplest fix here would be to do an interactive rebase of your branch:
git rebase -i HEAD~5
This will show you a list of the most recent 5 commits, from oldest to newest. I assume that the large file was not added more than 5 commits ago.
pick u39mask five commits ago
pick 3jd987d four commits ago
pick 9k27dbw three commits ago
pick j1937nd two commits ago
pick wfn83e9 last commit
Change pick
to edit
for all the commits where the large file might be present:
edit u39mask five commits ago
edit 3jd987d four commits ago
edit 9k27dbw three commits ago
edit j1937nd two commits ago
edit wfn83e9 last commit
Now save the file and the interactive rebase will begin. The rebase will pause at each commit you have marked with edit
. When that happens, you can manually delete the large file and then type git rebase --continue
to continue to the next commit. When all commits have been reapplied, the rebase is over, and hopefully you will have removed all vestiges of the troubling large file.
Edit:
If you are new to the Emacs environment in which the rebase commit file will open, press SHIFT + I to enter insert mode. Then change pick
to whatever you want, e.g. edit
. When you are done editing, press ESC then :wq to save and close. Then, the rebase will start.
Upvotes: 3