-
Start from the branch I need, in this case
main
git checkout main
-
Update the branch
git fetch -a -p && git rebase origin/main
-
Make the code changes I wanted
-
Check that I got everything I wanted to change, and I'm not including something I don't want to
git diff --word-diff=color --ignore-all-space
-
Stage everything (like a "pre-commit")
git add .
-
Make the commit with a descriptive message
git commit -m "message goes here"
-
Push changes
git push origin main
-
Interactive rebase (to squash commits, for example)
git rebase -i HEAD~2
-
Soft reset
git reset --soft HEAD~3
-
Push force with lease (useful for pushing local squashes, rebases, etc)
git push --force-with-lease