- Clone the source repo to a temporary folder on your computer using the bare option, and then navigate to the repo's folder.
Note: When cloning using the bare option, the folder name includes the .git suffix.
git clone --bare https://github.com/contoso/old-contoso-repo.git
cd old-contoso-repo.git-
Create a target repo, and make a note of the clone URL.
-
Run the following command to copy the source repo to the target repo.
git push --mirror https://dev.azure.com/contoso-ltd/MyFirstProject/_git/new-contoso-repoWarning: Using --mirror will overwrite all branches in the target repo which includes deleting any branches not in the source repo.
- If the source repository has LFS objects then fetch them, and copy them from the source repo to the target repo.
git lfs fetch origin --all
git lfs push --all https://dev.azure.com/contoso-ltd/MyFirstProject/_git/new-contoso-repo- Delete the temporary folder.
cd ..
rm -rf old-contoso-repo.git