3

I understand it is possible to delete everything locally and just start fresh but I wonder if there is an easier way when you do not require to keep anything done locally using git commands.

for example if I added bunch of files locally that I would like to remove and just download the latest master copy.

Please note: Reading the other questions (there are many; I read them before posting), git help & blog posts I wasn't sure if it's going to reset my repository or not which is why I posted this question; I imagine someone with the same exact issue might want to validate and that's what I have done through comments. and that is why I don't think its a duplicate although it might have the same response.

Ash
  • 564
  • 2
  • 5
  • 23

1 Answers1

9

To remove the git commit which you have added locally do:

git reset --hard HEAD^

To remove the remove the uncommitted files, do:

git clean -fd

check out other git Clean options here:

https://git-scm.com/docs/git-clean

and then do

git fetch
git rebase origin/master

or

   git pull
insomiac
  • 5,648
  • 8
  • 45
  • 73
  • I did git reset --hard HEAD^ and my head went back to one before my last commit, is that what is suppose to happen ? – Ash Jan 19 '16 at 23:36
  • if You have committed your changes use the first command else use the second one.. – insomiac Jan 20 '16 at 05:39