Useful git stuff
Last Update: 2024-12-14
git has a vast feature set for those, that want to clean up their merge requests (before and after the review, but not during).
First of: Use the command line tool. For merging other tools may be more useful, but please don't use anything more than that. 3rd party integrations are always different, learn the CLI once and be good at git forever.
List of useful commands
The list below is a list of useful, advanced git commands (so no just git commit -a -m "msg"
)
Command | Explanation |
---|---|
git commit --amend | Change the last commit (be sure you can change it on |
the remote! | |
git rebase --interactive <ref>~ | With this you can fixup your commit structure from |
the COMMIT-REF to the latest commit on the branch | |
git reset --soft <ref> | Remove all commits up to but not including <ref> |
and add modified files in staging | |
git commit --fix <ref> | Create a simple commit fixing something in a merge |
request, so you can simply rebase it away in the | |
future! | |
git add --patch <file> | Add only partial changes from a file |
Things you should to
git rerere
Did you ever get annoyed by rebasing onto the main branch and having to resolve conflicts, which you have previously resolved?
Enter git rerere, the solution to your git rebase
problems.