From the course: Complete Guide to Git

Unlock the full course today

Join today to access over 24,000 courses taught by industry experts.

Switch branches with uncommitted changes

Switch branches with uncommitted changes - Git Tutorial

From the course: Complete Guide to Git

Switch branches with uncommitted changes

- [Instructor] In this movie, we will discuss the issues that can arise when you try to switch branches while there are also uncommitted changes in your working directory. Let me demonstrate the issue. First, let's make sure that we're on the main branch or use git switch main to switch to it. Now let's make a change to the About.HTML page and I will edit the exact same line that we edited and put in a commit in the new feature branch. The title line, before we just made it about, let's change this to about the company instead. I'll save that file. Come back over here. We're on the main branch, right, on main branch and we have changes that are not staged for commit that are in our working directory. Now let's try switching branches, git switch and then the new feature branch. I'll hit return and you'll see Git gives me an error. It says your local changes to the following files would be overwritten by checkout. Of course, that's our About.HTML page and then it says, please commit…

Contents