Skip to content

Git ​

🔱 About Git Config files ​

The git configuration is usually done in these 3 different contexts:

  • system wide config
    • /etc/gitconfig
  • global (per user) config
    • ~/.gitconfig
  • local (per repository)
    • <repo-root>/.git/config

The final config will be merged in this order.

💡 TIP

You can display the final values with git config --list

📄 Included Config ​

We already modified the default system config file:

KeySectionDescription
editor[core]Defines code-server as git edit to open files.
autcrlf[core]Disables automatic line ending conversion. Should be handeled by the editor
helper[credential]Enables saving plain credentials for git remotes.
filesEncoding[i18n]Sets utf-8 as default encoding.
default[push]Uses simple branch name matching strategy.
lg1[alias]Adds alternate log output layout in graph style
lg2[alias]Adds extended graph log layout.
cfetch[alias]Adds alias for fetch with --prune and --tags . cfetch stands for clean fetch

There are also some Phabricator workflow inspired helpers:

KeySectionDescription
feature <branch>[alias]Starts a new feature branch from updates master and checks out the new branch.
wip[alias]Stages all current changes and creates a wip (work in progress) commit.
squish[alias]Takes all open workdir changes and add them to the latest commit.
pod[alias]Tries to push current branch to origin/dev.
poc <branch>[alias]Takes current branch and tries to push it to a new remote one.

Git bash Completion ​

Git bash completion is already enabled in the arkanum image.

Referenced Source Files ​

Dockerfile
ADD gitconfig-system /etc/gitconfig
RUN \
  echo "**** setup git ****" && \
  echo 'source /usr/share/bash-completion/completions/git' >> /etc/bash.bashrc
ini
[core]
    editor = code-server --wait
    autocrlf = False

[credential]
    helper = store

[i18n]
    filesEncoding = utf-8

[push]
    default = simple

[alias]
    # simplified logging views
    lg1 = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
    lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n''          %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all

    # fetch all remote changes
    cfetch = fetch --prune --tags

    ## Phabricator inspired workflow

    # Create new feature branch
    feature =  "!f(){ b=$1; git checkout master; git pull; git checkout -b "$b" master; };f"

    # adds a new wip commit
    wip = !"git add -A; git commit -m '[WIP]'"

    # used to squish changes in the latest commit. Should be used after a wip commit
    squish = !"git add -A; git commit --no-edit --amend"

    # Push to origin / dev branch
    pod = !"git push origin dev"

    # Push to custom remote branch
    poc = "!f(){ b=$1; git push origin "$b";};f"

Released under the AGPLv3 License.