| layout | post | |
|---|---|---|
| title | Git | |
| categories |
|
|
| visible | true |
$ git checkout HEAD Can't be undone
$ git checkout HEAD
$ git checkout -p
$ git reset --hard HEAD Can't be undone
$ git commit --amend -m "Correct" --amend rewrites history!
$ git revert <commit_hash>
$ git reset --hard <commit_hash> $ git reset --mixed <commit_hash> sets your HEAD
$ git checkout <commit_hash> -- -- means we are not talking about branch
$ git reflog $ git branch <branch_name> <commit_hash>
$ git reflog $ git branch <branch_name> <commit_hash>
$ git branch <branch_name> $ git reset HEAD~1 --hard
$ git checkout <branch_name> $ git cherry-pick <hash_commit> $ git checkout master $ git reset --hard HEAD~1
- How far you want to go? base
- $ git rebase -i HEAD~3
Fixing the last commit $ git rebase -i HEAD~3 then use reword option
$ git rebase -i HEAD~3 ...then use "squash" option
$ git add $ git commit --fixup <commit_hash> $ git rebase -i HEAD~4 --autosquash nothing to do in the next step