Reputation:
how to undo git commit and get the remote files copied back replacing the modified local files intended to be push but needs to be canceled and undone? (watch the plural)
Upvotes: 0
Views: 148
Reputation: 57
modified local files
can be discarded with stash
command (git stash save --include-untracked
, option --include-untracked for new file). This action will store all changes in repo in stash list.reset
command.
Example: you have 3 commits A - B - C, the current commit is C and you want to remove C, back to commit B, you can use: git reset <B-commit-hash>
. reset
have 3 options:
hard
: all change in commit C will be discardedsoft
: change of commit C will be in the staging areamix
: change of commit C will be in the working directory, mixed with current change (if any).After reset, your local repo has B commit as the latest commit. This time, your local repo can be different from the remote repo.
git push --force
. force
option will override the history commit-graph same as your local repo.git pull
I hope it's helpful for you
Upvotes: 1