a day ago
- Git has a great data model but an unfriendly user interface.
- If you lose a commit, run `git reflog` to find recent commits.
- After a rebase, use `git push --force-with-lease` instead of regular `git push` to avoid rejection.
- If you accidentally merge after `git pull`, use `git reset --hard HEAD~` to undo the merge commit.
- A detached HEAD means you're not on any branch; create a new branch with `git checkout --branch <name>` to save work.
- To overwrite untracked files, commit changes first or use `git submodule deinit` or delete files carefully.
- In rust-lang/rust, modify Cargo.lock by updating submodules with `./x.py --help`.
- Amend last commit with `git commit --amend`; fix earlier commits with `git commit --fixup` and `git rebase --autosquash`.
- Remove a merge commit by rebasing onto the default branch with `git rebase -i origin/HEAD`.
- Error messages in Git are often unhelpful; better messages would guide users to correct solutions.