Copy Branch from One Repo to Another in Git

Опубликовано: 12 Ноябрь 2023
на канале: ReactJS tutorials
4,903
12

#git #github #bitbucket
https://codingbeast.org/copy-branch-f...

How to copy a branch from one repository to second remote repository.

To transfer your branch (Branch A) from the old repository to a new one, you have two options. The first method involves adding a new remote (Organization) to your old repository (master) and then pushing Branch A to the new repository. Execute the following commands in your terminal:

cd old repository
git remote add origin2 new_url
git push origin2 branch A
This sequence adds a new remote and pushes Branch A to the new repository. Subsequently, your new repository should now include the newly transferred Branch A.

Alternatively, the second method allows you to update the current repository's remote to point to the new location and then push the branch. Use the following commands:

git remote set-url origin new url
git push origin branch A

Both approaches yield the same result; however, the distinction lies in the fact that the first method involves adding a new remote, while the second method modifies the existing remote to point to the new location. Choose the approach that best suits your workflow.


Смотрите видео Copy Branch from One Repo to Another in Git онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь ReactJS tutorials 12 Ноябрь 2023, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 4,903 раз и оно понравилось 12 людям.