Skip to content

Instantly share code, notes, and snippets.

@uxDaniel
Last active July 29, 2023 23:28
Show Gist options
  • Save uxDaniel/de6d23331f771d341acdf6f04e37a87a to your computer and use it in GitHub Desktop.
Save uxDaniel/de6d23331f771d341acdf6f04e37a87a to your computer and use it in GitHub Desktop.
My git flow

My usual git flow:

  • 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

Other useful commands

  • 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment