Shaun
Shaun

Reputation: 4167

Git repository from one machine to another

So I have a git repository that i pulled at one point and that repository resides on a server. I don't have access to the original repository that I pulled it from. How do i get the code from the existing server to another computer?

EDIT 1: So here's what it looks like:

Can i just do a simple copy of that directory without using git, or can I use git to clone if from B to C?

Upvotes: 21

Views: 44433

Answers (7)

Pjotrs Osnovskis
Pjotrs Osnovskis

Reputation: 103

If anyone has any issues with cloning, I used simply this, on the machine you want app to be cloned to:

  1. in CMD go to folder where you want your app to be cloned to, for example cd C:/my_apps/
  2. login to github and go to app you want to clone, press green button "Clone or Download", you will see SSH link, copy it.
  3. in CMD run git clone [email protected]:user/my-app.git (use SSH link you copied)

Done

Upvotes: 2

ivzhh
ivzhh

Reputation: 330

If I understand the question right, you just want to transfer the history of code from B to C. Actually because git uses de-centric model, B has complete history of the code till the last sync point between B and A.

I can think of three methods if you just want to transfer code history from B to C:

  • direct copy/rsync/etc. just copy all files and structures in \B-machine\code.git to \C
  • git clone: this is best choice if C can access B through http or ssh
  • git bundle: git supports bundle command, and after bundle, you copy/rsync/ftp/scp bundle file to C

Upvotes: -2

user1820956
user1820956

Reputation:

This is achieved by creating a clone of the repository that is on COMPUTER B, by running the command git clone on COMPUTER C, where you want the cloned repository to be created. Cloning in git can be done using multiple protocols, including ssh, https, git; and these require an appropriate setup for the git clone command to succeed.

The easiest approach is to start the git server on COMPUTER B using this command:

> git daemon

For help with the above command, run git help daemon

Then place a marker file in the .git folder of the repository on COMPUTER B to grant permission to the git server to run the clone command on that repository. This is done by:

> cd <repository root>/.git
> touch git-daemon-export-ok

Now, from a terminal on COMPUTER C, run the following commands:

> cd <folder in which to create the cloned repository>
> git clone git://<ip address of COMPUTER B>/<full path of the repository on COMPUTER B>

This will create the cloned repository on COMPUTER C.

Upvotes: 35

Sdra
Sdra

Reputation: 2347

You can run from computer C:

git clone username@computer_B:path/to/root/of/repository

assuming that computer B has a ssh server running. Otherwise other protocols are supported (file://, http://, \\computer_B (NetBios), ...)

Upvotes: 2

sdot257
sdot257

Reputation: 10366

You mean you wanna clone it to a different computer?

How about:

git clone ssh://myserver/path/to/myproject.git 

Upvotes: 1

Igor Zevaka
Igor Zevaka

Reputation: 76500

You can either pull from the network location or copy the entire directory(containing .git folder) accross to the other computer.

Upvotes: 8

Matt Enright
Matt Enright

Reputation: 7474

You can just clone it from the server, assuming you have access to where the clone is stored - the power of distribution ;)

Upvotes: 3

Related Questions