0

I wanted to put a lot of files in a repository. However, their size exceeds 10GB. And they are a lot of files. The total storage is around 13gb.

I am thinking of ways to go about this. Now I am thinking of creating a separate repository where I could push the rest of the files. But since there are many files, it would be too tedious to do that manually.

Is there some way to see which files have not been added to git (maybe they are called unversioned files)? and then remove all but the unadded files. And then init a new repo on the same folder and push the rest to the other repository.

Please let me know if this is possible. I am open to using shell or a python wrapper around git if that exists.

The files are unrelated to each other so it's not a big deal that they would be saved in two separate repositories.

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
informe
  • 9
  • 1

3 Answers3

0

To find files that haven't been committed:

git status --porcelain --untracked-files --ignored

This will show you all file paths with changes, including those in .gitignore, and descending into directories. If you have no pending changes in your repo, this should only be untracked/ignored files. There will be 3 chars at the beginning of the lines like ?? or !! representing the status that you can strip off with | cut -c 4- unless you want to parse them to distinguish different statuses.

From there - it would be easier to move these files to a different directory (rather than moving all the other files).

Jason S
  • 13,538
  • 2
  • 37
  • 42
0

List all tracked files:

git ls-tree --full-tree -r --name-only HEAD

Remove all tracked files:

git ls-tree --full-tree -r --name-only HEAD |
  xargs git rm

Remove the repository:

rm -rf .git

Create a new repository, add the files in the directory:

git init
git add .
git commit -m "Initial commit"
phd
  • 82,685
  • 13
  • 120
  • 165
0

My approach would be to purely use Git:

git status # Make sure you don’t have any change in already tracking files
cat .gitignore # If you ignore some files that you want to actually index, modify this file
git add . # Adding all untracked files
git commit # Take note of this commit hash, abcde123
cd ../another_new_repo
git init 
git fetch ../old_repo
git cherry-pick abcde123
Junji Shimagaki
  • 286
  • 2
  • 9