-2

Sorry for duplicating endlessly, but nothing has worked so far in the many posts I've read and in previous answers. I have been working on a project in a local repo, and, when I made my initial commits, they included a bunch of csv files that I don't want pushed to Github. After many commits, I added a .gitignore file with the single line *.csv which I understand will prevent future monitoring csv files in any directory of the project. I also understand that a .gitignore file won't stop git from pushing files in the commit history, even though I've asked for them to be "ignored."

Furthermore, I have tried cloning the project, but this doesn't seem to address anything. I think that this also clones the commit history, so nothing is achieved regarding a "clean history" that doesn't include the files I want ignored. Same errors when I try to push. After cloning, I also tried git filter-repo --path *.csv --force per some answers here, but this seemed to just delete everything in the cloned repo yikes! I've also tried the things always suggested, ie git rm --cached -r . and then git add and then comitting and pushing.

Does... anyone actually understand what I'm saying? Is there really not a solution that can be spelled out?

blaughli
  • 161
  • 2
  • 3
  • 11

1 Answers1

1

It's unclear what you think "cloning the project" is, or what difference it would make. You seem to understand that, if you have made a commit that includes these csv files, then if you push a commit that has that commit as an ancestor, those csv files will indeed end up on GitHub. So it is hard to know what the question is.

One way to prevent that is to rewrite history, as with git filter-repo. You seem to know about that too, so again, it is hard to see what question you have. You would use filter-repo to remove the undesirable files from the history, also remove them from the most recent commit, and then push.

One final alternative: if you don't care at all about any of your commit history, another option would just be to squash all your existing commits into a single commit and push it; since the csv files are not present in the most recent commit, they will not be present in the squashed single commit that comprises all the commits.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • despite "knowing about" the things I mention, I certainly don't know how to properly use them. I tried ```git filter-repo --force --invert-paths --path-match *.csv``` which I found at https://www.baeldung.com/git-remove-file-commit-history, but nothing changes. there are still "mysterious" csv files (which I don't even see in my working directory anymore) that blow up the push. – blaughli May 18 '23 at 20:25
  • How could csv files "blow up" a push? – matt May 18 '23 at 20:45
  • I mean that they're over 100mb, so I'm told that they exceed a size limit for github upload. I don't want any of them pushed, regardless of their size – blaughli May 18 '23 at 20:49
  • @blaughli In your [previous quesion](https://stackoverflow.com/q/76276753/7976758) there is [an answer](https://stackoverflow.com/a/76276781/7976758) `git filter-repo --path-glob '*.csv' --invert-paths` – phd May 18 '23 at 21:32
  • A csv file that's over 100MB is one heck of a csv file. – matt May 18 '23 at 22:01