Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Moving uncommitted changes to a new branch [duplicate]

Tags:

git

People also ask

How do you transfer uncommitted changes from one branch to another?

Create a new feature branch, say feature, and then switch to that branch. Implement the feature and commit it to our local repository. Push to the feature branch to the remote repository and create a pull request. After other teammate's review, the new change can be merged into the master or release branch.

What happens to uncommitted changes when you switch branches?

If the file is different on your other branch, Git will not let you switch branches, as this would destroy your uncomitted changes. It is safe to try switching branches, and if Git warns you that "uncommitted changes would be overwritten" and refuses to switch branches, you can stash your changes and try again.


Just create a new branch:

git checkout -b newBranch

And if you do git status you'll see that the state of the code hasn't changed and you can commit it to the new branch.


Just move to the new branch. The uncommited changes get carried over.

git checkout -b ABC_1

git commit -m <message>

Just create a new branch with git checkout -b ABC_1; your uncommitted changes will be kept, and you then commit them to that branch.