Daniel's Blog

Setting up git local dev environment

Config settings

There are some config settings that need to be set when setting up the local dev environment for git

These set your username and email, ensure that line endings are line feeds, will prune deleted branches on fetch, and will rebase on pull.

$ git config --global user.name "Your First and Last Name" 
$ git config --global user.email "Your Email" 
$ git config --global eol=lf
$ git config --global fetch.prune true
$ git config --global pull.rebase true

Rebase. Dont' Merge

When pulling changes from master into your development branch, always rebase. Do not create merge requests.

$ git checkout master
$ git pull
$ git checkout my-development-branch
$ git rebase master
$ git push --force origin my-development-branch

Other helpful settings

I use this all the time because I often need see the most recent part of the log when doing code reviews for other team members. Also, helping junior devs with incorrect git commits also causes this to be used all the time.

Tiny log

$ git config --global alias.lg "log --oneline -n 10 --graph"
$ git lg 
* 79e547464 (HEAD -> master, origin/master, origin/HEAD) Updated test instructions to account for test databases
* 223907efc (origin/release, release) Updated default help links in whitelabeling to the new freedesk help system pages
* a903b72d4 (print-statment-fixes) Added coverage config file and instructions to README and ignore entries for coverage reports
* 020c1d701 combined build steps into one and renamed. Images are tagged with the git sha and there are no differences betweeen them during building
* 42c234062 added help_text and comments to jobs and run_tool task
...