Category: PHP, git, javascript

Consider the scenario where you’re working on a Git branch called featureB and you have a lot of unstaged files in this branch. Now, for some reason, you don’t have to work on this branch anymore and switch to a new branch called featureX (which is currently non-existent) and apply all the unstaged changes to this branch.

There’s this git switch command using which it becomes fairly easy to switch between branches.

So, if you want to switch to the featureX branch from featureB, this is how you can do it using git switch. This command (with the option -c which means create) will create a new branch called featureX, switch to it, and apply all of the unstaged changes of the featureB branch.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners