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

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners