I am trying to:
- untrack two directories and their content (out/ & mybuild/) that were previously tracked
- remove them from the remote repository
- keep a local copy of the files inside these directories
Based on this post, I did the following:
git rm -r --cached out/
git rm -r --cached mybuild/
git commit -m "Remove directories out/ & mybuild/"
I still want an empty out/ directory in the remote repository, but do not need a mybuild/ directory. So, according to this post, I added mybuild/ to .gitignore in the main folder of the repository and created a .gitignore file inside the out/ directory that contains:
*
!.gitignore
and added the empty directory to the repository:
git add -f out/.gitignore
git commit -m "Add empty out/ directory"
After this, git ls-files
does not show any files in the mybuild/ directory and only the .gitignore file is present in the out/ directory.
Pushing the last commit to the remote repository however still contains untracked files in these directories:
[user@host]$ git push origin newbranch
Counting objects: 251, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (210/210), done.
Writing objects: 100% (214/214), 280.57 MiB | 4.20 MiB/s, done.
Total 214 (delta 93), reused 0 (delta 0)
remote: error: GH001: Large files detected.
remote: error: File mybuild/src/file1.dat is 269.99 MB; this exceeds GitHub Enterprise's file size limit of 100.00 MB
remote: error: File out/file2.dat is 188.17 MB; this exceeds GitHub Enterprise's file size limit of 100.00 MB
What am I missing? How could this be solved?
Update: db48x pointed out that, as the unwanted directories are present for a long time in my repository, removing them is a non-trivial task.
Running git filter-branch
to remove all cached files related to the out/ directory was not successful: checking out earlier commits and running git ls-files
shows that unwanted files in out/ directory are still present.
Following the other solution by db48x, I checked out an earlier commit in which the large files that are obstructing a git push
are not present (NOTE: it still contains a lot of unwanted files in the out/ & mybuild/ directories - just not the files that obstruct a git push
). Then created a new branch (named minimal) and repeated the steps explained above to remove all files in the unwanted directories. This partially solved the issue: The out/ and mybuild/ directories are effectively gone and it is possible to push the 'minimal' branch to the remote repository.
The only issue that remains is updating the source files of the project to the most recent version. Merging the old branch 'newbranch' and 'minimal' is successful and a git ls-files
run shows that no files in the out/ or mybuild/ directories are tracked by Git. Yet, git push origin minimal
now again fails due to files in the out/ and mybuild/ directories.
I do not have a clue about the reason of the inconsistent messages between git ls-files
and git push
and would appreciate directions for further diagnosing of the problem.