Skip to content

Git Config

Git can be configured by creating a .gitconfig file in your home directory. This is also where changes made with git config --global are saved.

Using this file you can make global changes that will be applied to each repo on your machine (unless overwritten in that repo).

# Pretty log format
[log]
    date = relative
[format]
    pretty = shortlog
[pretty]
    shortlog = format:%C(auto,yellow)%h%C(auto,magenta)% G? %C(auto,blue)%>(12,trunc)%ad %C(auto,green)%<(20,trunc)%aN%C(auto,reset)%s%C(auto,red)% gD
# Default git push behaviour
[push]
    default = current

default = current gives the following behaviour (git-config):

Push the current branch to update a branch with the same name on the receiving end. Works in both central and non-central workflows.

Per Repo Config

Each repo has a file in it at .git/config and this controls configuration for the repo you have checked out

Generall this is updated using git commands such as git branch and git remote however you can also edit it manually

Pushing Commits and Tags in One Go

If you are using a tagging workflow, it can be a pain to have to continously remember to push commits and tags separately.

You can configure things so that git push will always push all commits and tags

Open the .git/config file and find the [remote "origin"] bit and then make it look like this:

[remote "origin"]
    url = ...
    fetch = +refs/heads/*:refs/remotes/origin/*
    push = +refs/heads/*
    push = +refs/tags/*

[https://wincent.com/wiki/Pushing_branches_and_tags_with_a_single_%22git_push%22_invocation]