Revert changes to git since last click?

Newbie question: how to undo local changes in the git repository until the last click? I see a lot of hints for rolling back the last commit or all local changes, but not in this case.

+5
source share
4 answers

You will find the commit you want to return to (say foo), and then say git reset --hard foo. The next push you do should be a strong push if you want it to go through.

+6
source

Quick & Dirty way: delete the local branch and re-create it from the remote.

git checkout anotherBranch
git branch -D branchA
git checkout -b branchA origin/branchA
+3
source

, , .

- , , ...

git revert 
git push origin master #assuming you on master branch

-

git rebase --interactive and delete a specific set of changes

+1
source

You can do git reset for this. See Man git - reset.

In the git log, find the hash of the commit you want to return to. All changes after this commit are discarded.

By the way, here you will find a great book to learn git.

0
source

All Articles