1

Here's the output from > git status

MacBook:Ja.git alan$ git status
On branch alan-1
Your branch is up to date with 'origin/alan-1'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   Ja/App/App.xaml.cs

no changes added to commit (use "git add" and/or "git commit -a")
MacBook:Ja.git alan$ 

I made changes to the App.xaml.cs but didn't yet commit.

Not sure if it makes any difference but I am using Visual Studio as my front-end and I also have access to git on the command line.

How can I back out of the changes that I made and restore App.xaml.cs to the way it was before I edited it?

Can I do it from the Visual Studio menu here:

enter image description here

Alan2
  • 23,493
  • 79
  • 256
  • 450
  • Yes, you can stash your changes. They'll be temporarily stored. Check it [here](https://git-scm.com/docs/git-stash) for a start. – Romain Valeri Feb 20 '19 at 12:31
  • You can do 'git checkout filename' to revert the changes. – Kartik Chauhan Feb 20 '19 at 12:38
  • Hi Kartik, do you think that has the same effect as Revert File from the menu? – Alan2 Feb 20 '19 at 12:52
  • 2
    Possible duplicate of [Reset or revert a specific file to a specific revision using Git?](https://stackoverflow.com/questions/215718/reset-or-revert-a-specific-file-to-a-specific-revision-using-git) – phd Feb 20 '19 at 16:24
  • https://stackoverflow.com/search?q=%5Bgit%5D+restore+file – phd Feb 20 '19 at 16:24
  • https://stackoverflow.com/search?q=%5Bgit%5D+remove+local+changes – phd Feb 20 '19 at 16:24

1 Answers1

1

How can I back out of the changes that I made and restore App.xaml.cs to the way it was before I edited it?

Yes, git checkout -- filename has the same effect as "revert" command from the menu.

Instead of going to main menu, you can also locate the Changes window in Visual Studio (Team Explorer --> Changes) and revert from there.

Mike Makarov
  • 1,287
  • 8
  • 17