- important choices - extend functionality - vs alternative client
[background-color = "#124990"]
[color = "#fff6d5"]
== Fixing errors with Git
== Typical errors
- staging the wrong files
- wrong commit messsage
- committing the wrong file(s)
- deleting the wrong branch
- deleting the wrong commit
- committing sensitive files
== Compounding the gravity
- easier to fix before push
- more issues with shared commits
== Recommended approaches
- not pushed
** change history ok
- pushed
** fix issues and add a new commit
** revert commit with `git revert ...`
- changing history on pushed commits
** only if there is no other option
** team is small enough to manage this
== Relevant commands
- `git restore --staged <file> ...` - to unstage
- `git commit --ammend`
- `git rebase -i HEAD~n`
- `git revert <sha value>`
- `git reflog` + `git reset --hard <sha value>`
== Relevant commands - aftermath
- `git push --force-with-lease` is a safer option that will not overwrite any work on the remote branch if more commits were added to the remote branch