How to Setup and Clone a Remote Git Repo on Windows

How to git clone a repo in windows from other pc within the LAN?

To access the repo, you must either share it on 192.168.0.6 or must be the same domain user as the one that owns the file on 192.168.0.6.

If you share the directory on 192.168.0.6 (e.g. with share name myrepo), you access it with //192.168.0.6/myrepo.

If you are logged in on your box with a user accout that is known on 192.168.0.6, you could try accessing the repo through the administrative shares:

//192.168.0.6/c$/xampp/htdocs/...

Always use forward slashes.

Another alternative would be using SSH to access the remote machine.

GIT clone repo across local file system in windows

You can specify the remote’s URL by applying the UNC path to the file protocol. This requires you to use four slashes:

git clone file:////<host>/<share>/<path>

For example, if your main machine has the IP 192.168.10.51 and the computer name main, and it has a share named code which itself is a git repository, then both of the following commands should work equally:

git clone file:////main/code
git clone file:////192.168.10.51/code

If the Git repository is in a subdirectory, simply append the path:

git clone file:////main/code/project-repository
git clone file:////192.168.10.51/code/project-repository

How do I git clone from a Windows machine over ssh?

The easiest solution is to change the default Windows OpenSSH shell to bash. You can do this easily from powershell on the Windows machine:

powershell
New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\Program Files\Git\bin\bash.exe" -PropertyType String -Force

You may have to restart OpenSSH on the Windows machine and/or kill existing ssh connections from the client before it takes effect. Now you can clone without any extra -u option:

git clone ssh://windowsmachine/c/Users/unhammer/foo.git

(and if you previously specified uploadpack/receivepack, remove them from .git/config)

How to connect to a remote Git repository?

Now, if the repository is already existing on a remote machine, and you do not have anything locally, you do git clone instead.

The URL format is simple, it is PROTOCOL:/[user@]remoteMachineAddress/path/to/repository.git

For example, cloning a repository on a machine to which you have SSH access using the "dev" user, residing in /srv/repositories/awesomeproject.git and that machine has the ip 10.11.12.13 you do:

git clone ssh://dev@10.11.12.13/srv/repositories/awesomeproject.git

How to clone git repo from Windows to Linux?

Follow these steps:

  1. Create a bare repository on remote.

    I guess the answer provided by ad22 is good enough for you:

    mkdir -p myrepo.git
    cd myrepo.git
    git init --bare

    Otherwise, you need to find out how to create a bare repository on server.

  2. Copy or Memo the URL of that just created bare repository.

    (Of cause, you need to have the right for accessing the URL.)

  3. Add a new remote for your local repository.

    Since you already have a local repository,

    1. Right click in that repository, Click TortoiseGit -> Settings,
    2. Give the remote a shortname and URL you copied
    3. Add it and apply the setting.

    See:

    Sample Image

  4. Push to remote by right clicking in local repository and click Push item.

  5. In Push dialog,

    1. Select the remote you just added.
    2. Check the Push all branches checkbox if all branches can be public, otherwise you need push each branch one by one.
    3. Check the Include Tags checkbox if you want to push all tags.

    Sample Image

Suppose that's all. ^__^

How to create a remote Git repository from a local one?

I think you make a bare repository on the remote side, git init --bare, add the remote side as the push/pull tracker for your local repository (git remote add origin URL), and then locally you just say git push origin master. Now any other repository can pull from the remote repository.



Related Topics



Leave a reply



Submit