Skip to content

Instantly share code, notes, and snippets.

@joelhelbling
Last active April 18, 2023 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joelhelbling/8618a1b32ed41081bd01e2239c6ff5f9 to your computer and use it in GitHub Desktop.
Save joelhelbling/8618a1b32ed41081bd01e2239c6ff5f9 to your computer and use it in GitHub Desktop.

My Git Workflow Commands

I usually like to start by ensuring I've fetched everything new:

git fetch origin

I like to keep main up to date:

git co main && git pull

When I create a feature branch, I start from main:

git co main && git co -b my-new-feature

Periodically as I work, I like to create many, multiple commits, and keep them green:

{run tests} && git add -p && git commit -m"adds the thing to the other thing"

The first time I push, I make sure to setup the tracking branch with -u:

git push -u origin my-new-feature

I also like to aggressively keep current with main, so from my feature branch:

git fetch origin && git rebase origin/main

I also like to push frequently. All the rebasing can make things a bit more interesting, so I do this alot:

git push --force-with-lease

Whenever I've been away for a bit, I like to begin by pulling from the remote repository, and I prefer to pull with a rebase so that my local changes will be written after the new remote changes:

git pull --rebase

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