0

I tried to update my branch from master, but must have screwed something up (I don't know what). Now I have about 20 modified and untracked files I do not want in my branch.

How can I go back to the last commit or push I made, before I tried to update?

I've tried

git checkout 12345, getting the hash from git log but the files are still present.

Would anyone know what I could do?

MeltingDog
  • 12,714
  • 38
  • 143
  • 270

2 Answers2

1

You can try git reset --hard <commit_number> on your branch.

Alternatively if you want to go back to your last pushed version, you can try

git reset --hard HEAD

But please be mindful that this will erase all your untracked code permanently.

For more info, you can see this answer

Vinit Divekar
  • 647
  • 8
  • 22
0

Okay, so it looks to me like you're asking how to preform a hard reset on your local repository. Consider This:

git fetch --all
git reset --hard origin/master

If you're working from a branch, then replace "master" with whatever branch you're working out of. This will clean your current file structure and replace it with your last push to the origin.

NOTE: All Local Changes will Be Lost.

Hope this Helps!

armitus
  • 664
  • 5
  • 20