/ GIT

Default Git options

I started working with Git some years ago, and to be honest, it was not easy to pick up. It’s a huge beast, and there are several ways that can help tame it.

On the web, most articles that have this in mind focus on creating command shortcuts. In general, this goes like: instead of typing git pull --rebase, let’s create a gpr shortcut!

I wrote such a post earlier. Yet, I don’t think creating a lot of shortcuts improve the situation a lot. First, shaving off a few keystroke every now and then won’t tremendously improve one’s productivity. Plus, if it’s only about remembering, chances are the shortcut command will be even further aways from one’s mind because of the lack of meaningful semantics.

All in all, there is more to improve Git usability than just shortcuts. For example, my experience is that I tend to always need to type the same options with the same commands:

  • git pull --rebase
  • git rebase -i --autosquash

I nearly always pull with --rebase, and rebase with --autosquash. But I need to type those options every time anyway. Fortunately, Git allows to configure default options, either globally or for a single repo via the git config command:

git config --global pull.rebase true
git config --global rebase.autosquash true

Of course, this works for any command/option combination.

If it happens you do not want to use the option once, you can check the documentation e.g.:

--autosquash, --no-autosquash

If the --autosquash option is enabled by default using the configuration variable rebase.autoSquash, this option can be used to override and disable this setting.

Nicolas Fränkel

Nicolas Fränkel

Developer Advocate with 15+ years experience consulting for many different customers, in a wide range of contexts (such as telecoms, banking, insurances, large retail and public sector). Usually working on Java/Java EE and Spring technologies, but with focused interests like Rich Internet Applications, Testing, CI/CD and DevOps. Also double as a trainer and triples as a book author.

Read More
Default Git options
Share this