copy code from one repo to another git 1

copy code from one repo to another git

# checkout repository A
git checkout git@github.com:username/repoA.git
# cd into old repository
cd repoA
# change remote origin to the newely created repo (exemple repoB)
git remote set-url origin git@github.com:username/repoB.git
# push branch into repoB
git push origin 
# cd into new repository and pull branch
git checkout origin 
# finally don't forget to reset origin for repoA
git remote set-url origin git@github.com:username/repoA.git

Here is what the above code is Doing:
1. Checkout the repository you want to move a branch from.
2. Change the remote origin to the repository you want to move the branch to.
3. Push the branch to the new repository.
4. Checkout the branch in the new repository.
5. Reset the remote origin to the original repository.

Similar Posts