I've created a new remote repo and I'm trying to add some initial files to it. This includes 2 python scripts and 3 folders with data in them.
Using git add <filename>
does not stage my file, according to git status
. I am in the root directory of the local repo I initiated.
As a consequence, as I didn't initially know that the files weren't being staged (but assumed so and went commit -> push
), Git pushed the whole local repo. This included data files inside the data folders.
Some of these were too large (>50mb), so I deleted them from the folder. From here, I would be fine with retrying a full commit/push of the local repo, but Git is still somehow tracking these deleted files.
Why are these still present in a commit if I deleted them?
I Am on Windows 10 with Ubuntu WSL. I've tried on the command prompt, the Ubuntu terminal and these terminals as available on VSCode.
As well, I tried adding a .gitignore
file with lines for __pycache__/
and *.pyc
since, at some point, attempting to add a file called ld_funcs.py
only staged new file: __pycache__/ld_funcs.cpython-38.pyc
CodePudding user response:
using
git add <filename>
does not stage my file, according togit status
.
Then check if those files are currently ignored:
git check-ignore -v -- a/file
Replace a/file
by one of the files not staged.
If empty, make sure those files were modified first: Git would not stage a tracked file without any local modification.
deleted them from the folder. From here I would be fine with retrying a full commit/push of the local repo, but git is still somehow tracking these deleted files
First, deleting plus pushing does not mean your remote repository size will decrease, as past commits will still keep record of those large files.
You would need a git filter-repo --strip-blobs-bigger-than 10M
followed by a git push --force
(assuming this new repository is not actively used by others) before your big files are truly gone.
And you also need locally to add those files (or all folders) to the .gitignore
file, in order to make sure they are no longer tracked.