Date:

Share:

Quickly switch to new branch with unstaged changes in Git – Amit Merchant – A blog on PHP, JavaScript, and more

Related Articles

Consider the scenario where you work on a so-called Git branch featureB And you have a lot of unstaged files in this branch.

Now, for some reason, you no longer have to work on this branch and move to a new branch named featureX (Which does not currently exist) and applied all unstaged changes to this branch.

The usual way to do this would be…

  • First store the unmodified changes.
  • Contact and pay for this new branch.
  • Apply or place the previous storage on this branch.

This is quite a process that needs to be followed. But what if I told you, there is a command to do it all at once?

to enter git switch.

God git switch command

There it is git switch A command by which it is quite easy to switch between branches.

In particular, the scenario I mentioned earlier can be easily done using this command.

So if you want to move to featureX Branch m featureB, So you can do it using git switch.

and that’s it! This command (with the option -c Which means create) Will create a new branch called featureX, Go to it and apply all unstaged changes to the featureB branch.

For more information on this command – git-switch

Source

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Popular Articles