Most of my interactions with git CLI, especially for quick changes, is:

$ git checkout main
$ git pull
$ git checkout -b okken_something
< code changes >
$ git commit -a -m 'quick message'
$ git push

Then the code review and merge happen on the server.


Let’s break that down.

  • git checkout main
    • Start at the main branch.
  • git pull
    • Grab any changes from remote repo.
  • git checkout -b okken_something
    • Create and switch to a new branch to start work.
  • git commit -a -m 'quick message'
    • Commit changes.
    • The -a automatically “adds” changed and deleted files, but not untracked files.
    • See commit -a docs.
  • git push
    • Push to the remote repo.
    • Normally this would show an error that the branch name doesn’t exist on the remote.
    • However, I have a config setting that automatically creates a branch on remote.
    • config setting: git config --global push.default current
    • See push.default docs.

With Autocorrect

Even if I mistype a command, it will work:

$ git chkout main
$ git pll
$ git commt -a -m 'quick message'
$ git psh

This is due to this config change:

$ git config --global help.autocorrect 10

This tells git to automatically run a command that is misspelled, after 1 second. The 10 is 10 x 1/10 of a second. So 50 for 5 seconds, etc.

See also Configure Git to Autocorrect.