Home > Blockchain >  Cloning a remote repository and subsequent offline access to it
Cloning a remote repository and subsequent offline access to it

Time:03-24

Consider the following commands issued on a local computer:

git clone git://git.test.git # <- creates folder test in current folder
cd test # amongst other files/folders, this contains the .git subfolder
git branch -r # <- to show the remote branches

Suppose the output of this is:

origin/C
origin/B -> origin/master
origin/A

(1) Is the size of test\.git folder, the actual and complete size of the online remote repository including all branches and all commits in each of these branches? I understand that the objects in .git folder are possibly compressed and uncompressing them is likely to increase size of the test folder. That is okay since I would like to know the full compressed and yet complete size of the remote repository. I am not interested to know the full uncompressed size of the remote repository.

(2) Is it safe to turn off the internet connection now on the local machine and issue:

git checkout C

to checkout branch C or does each checkout after a clone need to access the remote repository again over the internet?


ETA: Following up on torek's comment:

When you run git checkout C, your Git is about to give you an error ("I could not find a branch named C")

I do not get this error. I obtained:

Branch 'C' set up to track remote branch 'C' from 'origin'.
Switched to a new branch 'C'

Indeed, as torek implied, running git checkout C --no-guess gave error:

error: pathspec 'C' did not match any file(s) known to git

CodePudding user response:

(1) Is the size of test.git folder, the actual and complete size of the online remote repository including all branches and all commits in each of these branches?

There might be some difference in the size, but yes, git clone gives you a complete copy of the repository and it will be roughly the same size as on the remote.

(2) Is it safe to turn off the internet connection now on the local machine and issue git checkout C to checkout branch C or does each checkout after a clone need to access the remote repository again over the internet?

Git is always in offline mode. With the exception of a handful of commands (fetch, push, pull being the most common) Git is always working from your local .git directory. You must explicitly tell Git to access the remote repositories.

Note that remotes don't have to be over the internet. You can, for example, clone a directory and experiment. git clone /path/to/some/other/repository.

  •  Tags:  
  • git
  • Related