TransWikia.com

How do I switch from a merged branch to an new branch?

Stack Overflow Asked by mohammad-23 on January 3, 2022

I accidentally started working on a merged branch, now I want go back to develop get the updated code and then create a new branch. Is it possible to do so, or is there a workaround?

2 Answers

Use the following commands:

git stash: It will stash your uncommited changes.

git checkout develop: Go to develop branch

git pull: Get the latest code

git checkout -b "new branch" : Create a new branch

git stash apply : It will add your uncommited changes made in the step 1

Answered by Chakreshwar Sharma on January 3, 2022

if you wanna undo commits check this: How do I undo the most recent local commits in Git?

if you just want to change branch and create a new branch run this in terminal:

git checkout -b (write the name you want)

by running this you will create a new branch and also will switch to it.

Answered by Eliftch on January 3, 2022

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP