1

I am new to git. I have one project where I keep on making changes and I add, commit and then push to the remote repo from the local VS Code. Now I have made some changes in my local repo. So when I do git status I see changed files in "RED COLOUR". But I do not want these change. I want to see my local repo in sync with the last successful push.

Expected Behaviour:

So, when I do git status I should see message as "your local repo is in sync with master repo". Also, when I switch to Local VS code. I should get the prompt as "External source is modifying the files" And if I say YES. I get back to the last successful push.

enter image description here

P.S: I want all these changes to completely GO AWAY as it they were never made.

Attempt made: I did git checkout. But after running it if I again type git status I again see these red files. I DO NOT Want to see these changes at all. Please help me here.

EDIT Image :2 After GitCheckout enter image description here

Community
  • 1
  • 1
Unbreakable
  • 7,776
  • 24
  • 90
  • 171

2 Answers2

1

Use the git checkout command as shown:

(use "git checkout -- <file>..." to discard changes in working directory)

Note that you need to include the names of the files in the git checkout command, or use git checkout . (note the trailing dot). A plain git checkout by itself won't do it.

Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285
0
git reset HEAD --hard
git clean -fd
Alg_D
  • 2,242
  • 6
  • 31
  • 63