Skip to content

Instantly share code, notes, and snippets.

@nasirkhan
Last active May 12, 2022 03:17
Show Gist options
  • Star 42 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save nasirkhan/5950948 to your computer and use it in GitHub Desktop.
Save nasirkhan/5950948 to your computer and use it in GitHub Desktop.
`git` discard all local changes/commits and pull from upstream

git discard all local changes/commits and pull from upstream

git reset --hard origin/master

git pull origin master

@kpit-nrangavkar
Copy link

Its worked for me

git reset --hard origin/[your master branch name]

git pull origin [your master branch name]

Thank You

@satheyogesh
Copy link

This really works.

@Plasmoxy
Copy link

thank <3

@marcoris
Copy link

This is so annoying. I read on all pages on the internet the same solution but it don't work. I always have the same modified files after fresh cloning and can't discard them. Even git stash && git stash drop don't work! git checkout -- . does also not work!

@keifgwinn
Copy link

I've had the same, but a git checkout latest --force worked for me

@SugaryChiu
Copy link

Thanks, that does works!

@chococococo
Copy link

Thanks! Worked like a charm

@VitorAugusto
Copy link

lol this one has saved my life and my job, tnx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment