0

I am newbie in using git. I need to pull some packages from my friend's git repository but there is no Internet connection in my computer. I need to pull them offline. Is there a way to do it?

  • 3
    No, you cannot pull from a remote repository without an Internet connection. – dobey Sep 29 '14 at 14:14
1

You'll (obviously) have to have access to his repository. You could copy his entire repository to a USB stick (make sure you copy all the hidden .git* files!) and access it that way. You can also set up network share and get access that way...

Once you have access to his repository its very easy to pull his changes into your repository (using a terminal):

cd "<your repo directory>"
git pull "<his repo directory>" "<branch>"

Where <your repo directory> is the path of your location git repository, <his repo directory> is the file path of his repository and <branch> is the branch you are trying to pull (you can see a list of branches using git branch; the branch marked with the star is your current branch).

In practice it could look like this:

cd "${HOME}/project"
git pull "/media/john/USB/repo" "master"

In other words: You can check out a repository from an offline source just as you would when using a server!

  • @alexandar255 thank you for your detailed answer I will try them out but one more thing, can I clone my friend's repository if he gives me the ip address of git server? I mean is there a command like 'git clone <ip>/repo.git' to connect to the git server? – sosa Sep 30 '14 at 6:26
  • That depends how that server is set up: if you have SSH access then you can just use git clone ssh://<username>@<server IP>/<path to repo>. There are other ways to run a git server (see git-scm.com/book/en/Git-on-the-Server-The-Protocols ), but SSH is the simplest to set up as almost every *nix server includes it by default. Your friend just has to add a user account for you on his server and make sure it has permissions to access to the repository files. Also I'd recommend setting up the remote repository as a bare repository (git init --bare) and then committing to it your files. – ntninja Sep 30 '14 at 19:38
0

You obviously can't access a Git repository on the internet without internet access. You can however clone the repository to a portable medium (e. g. with a Git environment for Windows in an internet café) and copy/move/clone it to your computer afterwards.

Please note that you can clone repositories from a local file system or a resource on a local area network, not just the internet, e. g.:

git clone /path/to/source-repository /another/path/to/destination-repository

Git GUIs usually allow you to do the same.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.