We are going to push the code of branch(branchA) to a new branch(branchB) in a different repository. branchA: Which you want to Push. branchB: Where you want to Push. Clone branchA locally in your machine. Remove the remote origin from above cloned branchA. Create a new branchB if not created yet. Add remote origin of branchB repository. Checkout branchB. Then Commit changes if you make any. Then Push the code in branchB. Clone URLs: BranchA Repo: https://github.com/Neptune998/NeptuneWorldA.git BranchB Repo: https://github.com/Neptune998/NeptuneWorldB.git Clone the existing repository from where you want to push the code i.e NeptuneWorldA . git clone https://github.com/Neptune998/NeptuneWorldA.git Now, checkout the branchA git checkout -b branchA Now check the branch. git branch -a Now we will remove the existing remote origin NeptuneWorldA and add remote origin NeptuneWorldB. Check the remote origin: git remote -v git remote rm origin Now add the origin of NeptuneWorldB. git remote add origin https://github.com/Neptune998/NeptuneWorldB.git Check the remote origin. git remote -v git checkout -b branchB Follow the steps we always do to push code. git status git add . git commit -m “Commit msg” git push -u origin branchB If you get warning to pull and you don’t want to add the existing code then use -f tag. git push -u -f origin branchB If you face any issue write in the comment section. Thanks for Reading !Follow these steps:
Detailed Steps:
Step1:
Step2:
Step3:
anonymous | Dec. 8, 2021, 10:12 a.m.
Brief and Short Great !