How to copy or mirror code from one git repository to a new Git repository for Windows Machine

The steps are mentioned Below:

Copy or clone the code to local folder from the Git repository: –

For that first open the bash shell and move to the desires folder by using ‘cd’ command. And then type the below command and press enter. Here it is assumed that ‘ssh’ keygen is already generated and set in Git settings.

git clone git@github.com:yourusername/yourreponame.git .

Now use the mirror command from Git bash to copy the code to the new repo: –

git push –mirror git@github.com:yourusername/yournewreponame.git

Sometimes push will not work if the ssh keys are not set properly. For that in windows 10 machine follow the below steps: –

Generate SSH key: –

In the git bash type the command –

ssh-keygen

Here we don’t need to pass any passphrase, so just press the ‘Enter’ for multiple times.

Now move to the directory location where the key pairs are generated: –

cd ~/.ssh

Now copy the content of id_rsa.pub file to the Git hub.

GitHUb>Settings>SSH and GPG keys > new SSh key.

Here paste the generated public rsa key.