开发者

Git repository from one machine to another

开发者 https://www.devze.com 2022-12-17 06:55 出处:网络
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 co

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:

  • COMPUTER A: The git repository that I originally checked out from. I don't have access to this anymore.
  • COMPUTER B: A shared server that I have the code checked out on.
  • COMPUTER C: A Local laptop.

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?


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.


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


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


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), ...)


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 git@github.com:user/my-app.git (use SSH link you copied)

Done


You mean you wanna clone it to a different computer?

How about:

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


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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号