Question

I've create a repository in GitHub and tried to commit files over the size limit. This caused an error message. I've then created a .gitignore file which I saved in the main directory of my project which include a rule to exclude all .csv files.

# History files
.Rhistory

# Example code in package build process
*-Ex.R

# R data files from past sessions
.Rdata
.Rd

# .csv files which in this case are too heavy (> 100mb)
# You can download training and test datasets at this URL --> http://www.kaggle$
.csv

I've then tried to commit it again but unfortunately Git tries to commit also the .csv files along with the new create .gitignore file.

Considering the .gitignore way didn't sort my issue I've tried to remove the cached file using this command and tried to push again:

$ git rm --cached data/train.csv data/test.csv
$ git commit -m "Remove heavy .csv files
$ git push -u origin master

Unfortunately also in this case Git is trying to upload the .csv files. I think I need to origin the master branch because in GitHub the repository is still empty.

BTW, a git status command returns no new files to commit. The

$ git status
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       data/
nothing added to commit but untracked files present (use "git add" to track)

What should I do?

Was it helpful?

Solution

Considering that:

  • your most recent GitHub repo is empty,
  • and that you have already committed your large file (meaning no amount of git rm --cached will purge that file: it removes it only from the index)

Ianh's advice is the easiest:

  • reinitialise a new local repo,
  • write first your .gitignore file (with *.csv, not .csv)
  • then add everything (all .csv files won't be added)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top