Git Command to Discard All Local Changes/Commits | SJB -->

This website uses cookies to ensure you get the best experience. More info...

Pages

Git Command to Discard All Local Changes/Commits

If you are wondering how you can discard all your local changes easily, this post will show you how to do that in your git repository..

Git-Branch is Ahead of origin/master By n Commits
First, use git clean command to remove all the untracked directories or untracked files.
 
git clean origin
Now run this command, which will do the discarding job.
 
git reset --hard origin/{MyBranch}
Change {MyBranch} to your working branch.
If you are working on the SquashingBugs branch, your command will be_
 
git reset --hard origin/SquashingBugs
Happy coding!

No comments:

Post a Comment