How to Clone a Git Repository Which Is Present on a Remote Linux Server into Windows

How to clone a git repository which is present on a remote linux server into windows

You can't, without configuring your Apache in order to server git request.

The fact that your mysite.git is within Testsite doesn't make it accessible to git.

As shown in this config, you can define in a separate VirtualHost (so in a separate port, since you are already using port 80/443 on Testing) a config in order to call the git script able to interpret a git clone request:

ScriptAlias /hgit/ /path/to/git/libexec/git-core/git-http-backend/
SetEnv GIT_HTTP_BACKEND "/path/to/git/libexec/git-core/git-http-backend"
<Location /hgit>
...
</Location>

As for ssh, the right url would be:

git clone ssh://account@XX.XX.XX.XX/var/www/html/Testsite/mysite.git 

And it would work only if you generate a public and private (non-passhrase protected at first), and publish the public key in the ~account/.ssh/authorized_keys.

Or the sshd (ssh daemon) on the server won't recognize you (hence the password request), and won't know where "Testing/" is.

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

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 do I clone a Git repository into a specific folder?

Option A:

git clone git@github.com:whatever folder-name

Ergo, for right here use:

git clone git@github.com:whatever .

Option B:

Move the .git folder, too. Note that the .git folder is hidden in most graphical file explorers, so be sure to show hidden files.

mv /where/it/is/right/now/* /where/I/want/it/
mv /where/it/is/right/now/.* /where/I/want/it/

The first line grabs all normal files, the second line grabs dot-files. It is also possibe to do it in one line by enabling dotglob (i.e. shopt -s dotglob) but that is probably a bad solution if you are asking the question this answer answers.

Better yet:

Keep your working copy somewhere else, and create a symbolic link. Like this:

ln -s /where/it/is/right/now /the/path/I/want/to/use

For your case this would be something like:

ln -sfn /opt/projectA/prod/public /httpdocs/public

Which easily could be changed to test if you wanted it, i.e.:

ln -sfn /opt/projectA/test/public /httpdocs/public

without moving files around. Added -fn in case someone is copying these lines (-f is force, -n avoid some often unwanted interactions with already and non-existing links).

If you just want it to work, use Option A, if someone else is going to look at what you have done, use Option C.

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

Using GIT to clone from a windows machine to a linux webserver (in house)

Here is a walkthrough someone else did. It goes step by step showing how to do what you want.

How to get Git to clone into current directory

The solution was using the dot,
so:

rm -rf .* && git clone ssh://user@host.com/home/user/private/repos/project_hub.git .`

rm -rf .* && may be omitted if we are absolutely sure that the directory is empty.

Credits go to:
@James McLaughlin on comments



Related Topics



Leave a reply



Submit