kmccoy
kmccoy

Reputation: 2861

How to clone git repo from Windows to Linux?

I previously kept a bare git repository on a Linux server and a working copy in my local Windows laptop for development (syncing to the server using TortoiseGit over ssh). The server version was deleted/lost so I want to recreate the repo on the server using the latest commit from the local working copy on the Windows machine.

What is the best way to create this new remote bare repo copy on the remote Linux server from the Windows working copy?

Upvotes: 3

Views: 2602

Answers (4)

Yue Lin Ho
Yue Lin Ho

Reputation: 3111

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:

    enter image description here

  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.

    enter image description here

Suppose that's all. ^__^

Upvotes: 1

RaviTezu
RaviTezu

Reputation: 3125

On your Windows machine:

git clone --bare /path/to/local-working-copy-of-the-repo

The above command will create local-working-copy-of-the-repo.git folder.
Now copy the folder(bare repository) on to the Linux server.

Hope this helps.

Upvotes: 0

ad22
ad22

Reputation: 375

You can re-create the linux server repo using

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

On the local copy, assuming the remote URL is the same, do

git push origin <branch refspec>

for example

git push origin master

Note: If the remote URL has changed you can use

git remote set-url origin <new-url>

Upvotes: 5

Vampire
Vampire

Reputation: 38639

Just create the repo on the server, then add the repo to your local one as remote if it is not the same location as before and push to it.

Upvotes: 2

Related Questions