Home > Back-end >  Do you keep all files on GitHub after pushing, deleting and pushing again from local?
Do you keep all files on GitHub after pushing, deleting and pushing again from local?

Time:10-20

This may be a beginner question since I haven't interacted much with GitHub. But I wanted to know if the following workflow was possible

  1. Push some files of a folder to GitHub
  2. Delete those files from Local Machine
  3. Push new files to the same GitHub folder All while keeping both the previous and newer files in the GitHub repo folder.

The reason for this workflow is because I am working with a lot of 15 GB files and I'm running out of space locally. So I thought I could push those files to Git in chunks after I'm done working with them, delete them, get in new files, and then push them to the same place in Git again. In the end, I want all of my files on GitHub from the same folder, while they may/may not be on local. Is this possible?

CodePudding user response:

I think you shouldn't use git for 15GB files. Because git designated for code hosting and working with plain text files. For file storing it is not powerfull. It works. But for this you can use file storing services.

CodePudding user response:

Theoretically this is possible. But it's bad git practice as your local and your remote repo will be out of synch with each other. If this is for web development, I would definitely suggest using a service like AWS S3 or even Imgur. If these are large datasets, then I would suggest using a Database hosting service.

CodePudding user response:

Git does not work with individual files, other than as part of commits, which contain a complete snapshot of the repository in a particular state. It also treats all copies of the repository - including the one on your local computer - as equal, and expects each one to contain a complete copy of the entire history of the repository. So even "permanently" deleting a large file in the current revision of your repository won't free up space.

Git is a source code versioning system, designed for use with large collections of small text files, generally no more than a few kilobytes in size. It does not have rich support for binary files, and is not at all suitable for files on the order of gigabytes.

There are plugins such as git lfs which allow you to track versions of large files without storing them inside the repository itself. It is supported by GitHub and other hosting providers.

Alternatively, separate your data from your code, and store the large files in a data store, referencing them dynamically in the code.

  • Related