Cloning Repository Question

I’m new to GitHub. I am in another person’s repository and I already have all the files stored in my local machine. How can I clone the repository without needing to receive the objects stored in the repository?

Depends: By “all the files”, do you mean the source files, or a .git/ directory containing all the git objects?

In the latter case you can add the Github repository as a remote and fetch. Git will only retrieve objects it doesn’t already have.

In the former case you still need to download all the git objects, which include all the source files, so there’s nothing gained by trying to use the existing files. Just clone as usual.

1 Like

Sorry for the clarity issues of my question. I was referring to the source files when I said “all the files”.

The files in the repository have huge file sizes and since I have limited data plan, I am finding a way to clone the repository without having to recieve the objects from it. Is there no way for this?

I’m afraid not, the objects are part of the history, and you need the full history to work with git (with very few exceptions).

However, a repository can be copied as files, just make sure to also get the .git directory and its content. So if you can clone somewhere without a limited plan and e.g. copy the files to a USB stick that will work. Same if someone who already has the repository can give you a copy.

1 Like