From the course: Working with LinkedIn Learning Exercise Files on GitHub

Roll back local branch changes with Restore - GitHub Tutorial

From the course: Working with LinkedIn Learning Exercise Files on GitHub

Roll back local branch changes with Restore

- [Instructor] Let's take the same scenario. I'm going to make a change in line 22, save my changes, and attempt to switch to another branch. And if I choose Force Checkout, this will undo the changes. So force to check out. It says, are you sure you want to do that? All uncommitted changes will be permanently lost. In this case, uncommitted means uncommitted to the repository. So if I say Yes, I switched over to branch two. I can see the counters, what I expect over here on line 26. And then I switch back to branch 11. The counter has changed, but I've got the original string value here. So that's one way of handling this. I'll show you the technique that I usually use. So let's make a change. Save the changes. And then you can just go to Solution Explorer, right-click on the file, and you can see that it has changed. It's got that red checkmark next to it. You can right-click here and go to Git and choose Undo Changes. So either one of these techniques works. We basically undo any changes, so that we can safely switch to another branch.

Contents