how to copy a branch to a new repo and merge it with its existing branch?

preview_player
Показать описание
Here are the commands:
1) git checkout [branch name A] - "Checkout to the branch that you want to push/copy files from"
2) git remote add new [remote_repository] - "Add your new repo where you want to keep this branch/branch files"
If new remote already exist, change the new using below command
3) git remote set-url new [new remote URL]
4) git push new [branch name A] - "Push this branch to the new repo"

Repeat the above command for use case 2 and continue with the below:
1) git remote set-url origin [your new repo URL here]
2) git checkout [main branch name]
3) git merge [branch name A] --allow-unrelated-histories
1. Press "i" (i for insert)
2. Write your merge message
3. Press "ESC" (escape)
4. Write ":wq" (write & quit)
5. Then press enter
4) git push -u origin [main branch name]
Рекомендации по теме
Комментарии
Автор

Saved a ton of work for me man.... You are the best !! 😇

BoonAaron
Автор

Thanks a ton... saved me a lot of work..🙌

vishwasshenoy
Автор

Thank you so much Jagadeesh. It’s very helpful

sureshgply
Автор

it helped me a lot . thank you so much

fereshtehakhbari
Автор

is it a copy or a move? after adding to the new repo, does the files in the other repo get deleted?

knowledgenookhub