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!

Related Questions

How to write a range syntax in Peg JS

2  Asked on March 3, 2021 by hemraj-rijal


How to randomize two characters in multiple Lines?

4  Asked on March 3, 2021 by malgosh


How can I connect to a VPN in docker not using VPN images?

2  Asked on March 2, 2021 by tiago-machado


Prevent infinite recursion in c++

4  Asked on March 2, 2021 by joo-menicucci


Convert data.frame to time series

1  Asked on March 2, 2021 by davide


Border behind grid line

2  Asked on March 1, 2021 by ronara


React redux prop object property undefined

1  Asked on March 1, 2021 by bbarriatos


.gitignore doesn’t work in windows terminal

2  Asked on February 28, 2021 by a100d


Get specific values

1  Asked on February 28, 2021


Copy locust file into volume via YML in kubernetes

1  Asked on February 28, 2021 by moses-liao-gz


Ask a Question

Get help from others!

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