• Stars
    star
    133
  • Rank 272,600 (Top 6 %)
  • Language
    Shell
  • Created almost 14 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

gitconfig setttings, files, aliases, colors, branches, etc.

gitconfig settings

Git configuration settings, files, aliases, branches, merges, syntax coloring, merges, credentials, and more.

Examples:

  • Nicknames such as git s doing git status
  • Workflows such as git rbi doing a rebase, interactively, on unpushed commits.
  • Helpers such as git optimize doing a prune and repack.

For the complete list, see the files in the gitconfig.d directory.

Install

Install for novices:

  1. Get these files:

    git clone https://github.com/SixArm/sixarm_git_gitconfig.git

  2. Create your own personal .gitconfig file, or edit your existing file, such as:

    edit ~/.gitconfig

  3. Add these lines:

    [include] path = sixarm_git_gitconfig/gitconfig

Install for experts:

  1. If you want full control, then you can copy any of these files and edit them as you like.

  2. The alias.txt file has the bulk of the items - start with that file.

  3. If you want to include some files, but not others, then you can use this syntax:

    [include] path = sixarm_git_gitconfig/gitconfig.d/alias.txt path = sixarm_git_gitconfig/gitconfig.d/color.txt

Install for specific operating systems:

  1. If your system is OSX, and you want to enable the keychain credential manager, then add this:

    [include] path = sixarm_git_gitconfig/gitconfig.d/specific-to-osx.txt

  2. If your system is Windows, and you want to enable the system credential manager, then add this:

    [include] path = sixarm_git_gitconfig/gitconfig.d/specific-to-windows.txt

Alias shortcuts

One letter shortcuts are for fast typing:

a = add
b = branch
c = commit
d = diff
f = fetch
g = grep
l = log
m = merge
o = checkout
p = pull
r = remote
s = status
w = whatchanged

There are many two letter shortcuts for popular commands and options, such as these:

ap = add --patch
be = branch --edit-description
ci = commit --interactive
ds = diff --staged
lg = log --graph
ss = status --short

To see the complete list, please see the files in the gitconfig.d directory.

Favorites

Here are some of our alias favorites that we use often:

Get everything new:

get = !git pull --rebase && git submodule update --init --recursive

Rebase interactive on our unpushed commits:

rbi = !git rebase --interactive @{u}

Summarize changes for a daily standup meeting:

log-standup = !git log --since yesterday --pretty=short --author `git config user.email`

Find text in any commit ever:

grep-all = !"git rev-list --all | xargs git grep '$1'"

Publishing

Here are a couple our favorites for publishing. For the complete list, see gitconfig.d/alias.txt.

Publish the current branch by pushing and tracking:

publish = "!git push -u origin $(git branch-name)"

Unpublish the current branch by deleting the remote branch:

unpublish = "!git push origin :$(git branch-name)"

Cleaning

Here are some of our favorites; for the complete list, see gitconfig.d.

Prune stale items:

pruner = !git prune --expire=now; git reflog expire --expire-unreachable=now --rewrite --all

Repack the way Linus recommends:

repacker = !git repack -a -d -f --depth=300 --window=300 --window-memory=1g

Delete all branches that have been merged into master:

master-cleanse = !"git checkout master && git branch --merged | xargs git branch -d; git branch -r --merged origin/master | sed 's/ *origin\///' | grep -v '^master$' | xargs -I% git push origin :% 2>&1 | grep --colour=never 'deleted'"

Feature Flow

Alias configuration for our feature flow. For details, see gitconfig.d/alias-for-feature-flow.txt.

Create a new feature branch:

feature-start = '!branch=$1; git checkout master; git pull; git checkout -b "$branch" master'

Update the feature branch:

feature-update = '!branch=$(git branch-name); git checkout master; git pull; git checkout "$branch"; git rebase master'

Share the feature branch:

feature-share = '!branch=$(git branch-name); git push -u origin "$branch"'

If your team uses a different feature flow, you may want to skip including these aliases, or you may want to edit these aliases to match your team's feature flow.

User personalization

If you use the user.txt file, you will want to personalize it:

[user]
  email = [email protected]
  name = Alice Anderson

GitHub personalization

If you use GitHub and the github.txt file, you will want to personalize it:

[github]
  user = alice
  token = alice-token

Customization

You can customize any of the file items by editing the file as you like.

You can also customize any of the file items by adding your own item later in your own gitconfig file.

For example you can include our aliases then customize "git l" with your own definition:

[include]
   path = ~/.gitconfig.d/alias.txt

[alias]
   l = log --graph --oneline

Format

To use better pretty formatting:

[format]
  pretty = "%H %ci %ce %ae %d %s"

Status

If you like terse status messages:

[alias]
  s = status -sb

Log

If you like log summaries:

[alias]
  l = log --graph --oneline

Meld merge tool

We like using the meld mergetool because it is powerful and can use three windows for comparisons.

This repo includes a script for running meld with three windows.

To use meld with three windows, put the script on your path, for example:

cp bin/meld-with-three-windows /usr/local/bin

Most pager

If you prefer using most as a pager:

[core]
  pager = most

To get most, do brew install most on OSX, or apt-get install most on Ubuntu, etc.

Suggestion for branch auto setup merge

We tell git-branch and git-checkout to setup new branches so that git-pull will appropriately merge from that remote branch.

git config --global branch.autosetupmerge true

If we didn't do this, we would have to add --track to our branch command or manually merge remote tracking branches with "fetch" and then "merge".

Suggestion for tab completion

To install git tab completion, we go to the git source code directory then run:

echo "source ./contrib/completion/git-completion.bash" >> /etc/bash.bashrc

Suggestion for git GUI apps

Read http://git.or.cz/gitwiki/InterfacesFrontendsAndTools

Our favorite open source free GUI for Ubuntu is http://cola.tuxfamily.org/

Stash

A recent addition to git which defaults the -p flag to git stash show. This makes git stash show show the diff from that stash. In our opinion, this should be the default.

git config --global stash.showPatch true

Autostash

Automatically stash and unstash the working directory before and after rebases. This makes it possible to rebase with changes in the repo.

git config --global rebase.autostash true

Decorate

Always decorate git log.

git config --global log.decorate full

Autosquash

Setting autosquash enables it by default for all interactive rebases. When committing you can specify --squash=<commit> or --fixup=<commit>, then git rebase -i --autosquash will automatically move and mark the relevant commits in your rebase queue.

rebase.autoSquash true

User config

We prefer to be explicit about user configuration, rather than to use the default user configuration, which looks for a local identity, then looks for a global user identity, then tries to guess a user identity based on your current user and machine.

user.useConfigOnly true

The useConfigOnly setting mandates an explicit configuration. Then we can remove any global git user and/or git email. Then git will require the correct configuration of any local repository before allowing commits.

Commit intent

When performing a rebase (interactive or not) it can be difficult to remember what the original intent of a specific commit is when it's mixed with conflict markers. This shows the original commit being rebased.

alias.original "!git show $(cat .git/rebase-apply/original-commit)"

Recursive git

If you accidentally type git git foo, then correct it.

alias.git "!git"

Merge tool

merge.tool <yourtool>

Will automatically use the specified tool when invoking "git mergetool", if you like external utilities to perform merges or conflict resolution (

Try these: emerge, kdiff3, araxis, vimdiff3, meld. The list of builtin tool support is accessible via "git mergetool --tool-help".

FF

This has saved me:

git config  --global pull.ff only

I can always override an individual pull invocation with either "git pull --rebase" or "git pull --no-ff". This makes it a conscious choice when a fast-forward pull is not possible.

If you set this config, and a fast-forward pull is not possible, here is what git does:

$ git pull
fatal: Not possible to fast-forward, aborting.

Signing vs. fast forward

If the workflow rule is that merge commits to master are not permitted (ie. all commits must be rebased onto master first), then one person cannot rebase someone else's signed commits without losing those signatures.

Theoretically one could devise a tool which allows each contributor to re-sign (in the correct order), but I'm not aware that any such thing exists, and it'd probably be too impractical anyway.

In a shared repository, I prefer creating "useless" merge commits to changing other peoples signatures.

diff-so-fancy

I really like diff-so-fancy [1] highlighter as a pager and to review diffs. Previously discussed here on HN here: [2]

force with lease

If we are stuck and we must push with force, then we use this:

git push --force-with-lease

Instead of:

git push -f

The advantage of the former over the latter is that it won't push if we haven't already seen the ref we're overwriting. It avoids the race condition of accidentally "push -f"ing over a commit we haven't seen.

In our opinion, this should be the default.

Log format

Log format with condensed view, graph, and tags:

lg = log --pretty=format:\"%C(yellow)%h%C(reset) %C(green)%ad%C(reset) %C(red)|%C(reset) %s %C(bold blue)[%an]%C(reset)%C(yellow)%d%C(reset)\" --graph --date=short

Log forward that shows dates at the end, in a relative format (2 days ago, 29 hours ago, etc) and the tags/branches before the commit message:

lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen%cn%Creset %Cblue(%cr)%Creset' --abbrev-commit --date=relative

Another:

lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit

Yellow

One thing I like to do is alter the coloring as an aide for git status which is giving "changed" a yellow as an intermediary color:

[color "status"]
  untracked = red
  changed = yellow
  added = green

Vim diff

I'm a long time vim user and my brain is wired to reach for the keyboard shortcuts in vimdiff to jump from diff to diff.

Also, I really love diffing entire trees in one vim session using the DirDiff plugin (https://github.com/will133/vim-dirdiff).

Here's how I wire it into my .gitconfig, which gets me the alias "git dirdiff":

[difftool "default-difftool"]
  cmd = gvim -f '+next' '+execute \"DirDiff\" argv(0) argv(1)' $LOCAL $REMOTE

[difftool]
  prompt = false

[alias]
  dirdiff = difftool --dir-diff
~~

I like to use gvim to open new windows separate from my terminal, but if you prefer you can just use plain vim in there as well.

Also, if using vim for viewing diffs, you might want to hack vim's config as well to make it look good. I like to (effectively) disable folding of lines with no diffs so I can still read the whole file- I use the shortcuts ]c (next diff) and [c (previous diff) to jump around diffs. I also like to disable editing in diff mode.

Here's my diff-related .vimrc hackage:

~~~vimrc
if &diff
  set lines=60 columns=184
  set foldminlines=99999
  set nomodifiable
  set nowrite
endif

reply

tmux

I have a dedicated Git tmux tab for every repo I'm working on, in that tab I use a git shell. Initiated by this bash function:

# A nice shell prompt for inside git repostories
# Shows a short status of the repository in the prompt
# Adds an alias `g=git` and makes autocomplete work
gitprompt() {

    __color_bold_blue='\[$(tput bold)\]\[$(tput setaf 4)\]'
    __color_white='\[$(tput sgr0)\]'

    export GIT_PS1_SHOWDIRTYSTATE=true;
    export GIT_PS1_SHOWSTASHSTATE=true;
    export GIT_PS1_SHOWUNTRACKEDFILES=true;
    export GIT_PS1_SHOWUPSTREAM="auto";
    export GIT_PS1_SHOWCOLORHINTS=true;
    . /usr/lib/git-core/git-sh-prompt;

    local ps1_start="$__color_bold_blue\w"
    local ps1_end="$__color_bold_blue \\$ $__color_white"
    local git_string=" (%s$__color_bold_blue)"

    export PROMPT_COMMAND="__git_ps1 \"$ps1_start\" \"$ps1_end\" \"$git_string\""

    # Short alias for git stuff
    alias g=git

    # Make autocomplete also work fo the `g` alias
    eval $(complete -p git | sed 's/git$/g/g')

}

So I have this in my .bashrc and when I want my bash to get a handy Git prompt I type gitprompt.

You do need the file git-sh-prompt which should come with git, for me it's located in /usr/lib/git-core/git-sh-prompt. It's also available here:

fsckobjects

Don't set fsckobjects=true. There are normal repositories that have broken trees which will not download if you have it set. Yes it is irritating and I would rather turn it on, but I had to turn it off after several repos failed for me.

The fsckObjects settings are entirely separate from the SHA. They are about syntactic and semantic rules in the objects themselves (e.g., well-formatted committer name/dates, tree filenames that don't contain "/", etc).

Git doesn't check validity of commit hashes by default.

Merge/diff tools

  • The merge/diff tool I use is p4diff, which comes with P4V (Perforce visual client) and is free.

tig

To explore the git log, I use tig. https://github.com/jonas/tig

It is a curses interface to git. Screenshot: https://atlassianblog.wpengine.com/wp-content/uploads/tig-2....

GPG with keybase.io to sign commits

Shameless plug. I published a little guide some months ago, on how to use GPG with keybase.io to sign commits.

Link: https://github.com/pstadler/keybase-gpg-github

Discussion on HN: https://news.ycombinator.com/item?id=12289481

More

For more git config ideas, and for credit for many of the aliases here, please see these excelent resources:

Thanks

More Repositories

1

unix-shell-script-tactics

Unix shell script tactics - best practices style guide
Shell
270
star
2

zsh-config

SixArm.com → Z shell → zsh configuration
Shell
210
star
3

sixarm-macos-setup

SixArm.com » Mac » Setup notes for new Mac computer and macOS
Shell
58
star
4

gpg-encrypt

Use GPG to encrypt a file using our best settings
Shell
58
star
5

sixarm_unix_shell_scripts

SixArm.com » Unix » shell scripts for command line programs in sh, bash, etc.
Shell
55
star
6

usv

USV: Unicode Separated Values, the standard for data markup of units, records, groups, files
Shell
53
star
7

rust-guideposts

Rust Guideposts are for developers learning Rust, who want quick topic summaries about the Rust language, ecosystem, concepts, crates, and more.
Rust
45
star
8

assertables-rust-crate

Assertables: a Rust crate of assert macros for testing
Rust
41
star
9

tmux-conf

tmux configuration files with annotations
35
star
10

unix-shell-script-kit

Unix shell script kit with many utility functions, constant exit codes, and POSIX helpers.
Shell
25
star
11

BoldContacts

BoldContacts mobile app for people with visual/cognitive/motor disabilities
Swift
24
star
12

sixarm_mac_osx_installation_help

SixArm.com » Mac OSX installation help, notes, and guides
Shell
23
star
13

kill-palo-alto-networks-global-protect

Kill Palo Alto Networks Global Protect VPN software
Shell
20
star
14

curl-chatgpt

Curl shell script to connect to OpenAI.com ChatGPT API
Shell
16
star
15

sixarm_ruby_unaccent

SixArm.com » Ruby » Unaccent replaces a string's accented characters with ASCII characters.
Ruby
16
star
16

cargo-install-favorites

Use the `cargo` command install our favorite crates
Shell
15
star
17

pandoc-from-markdown-to-pdf

Use pandoc to convert from markdown to PDF with our preferred options
Shell
15
star
18

pitch-deck-template

SixArm® pItch deck template
14
star
19

project-management-rope-estimate

Project management ROPEâ„¢ estimate: realistic estimate, optimistic estimate, pessimistic estimate, equilibristic estimate
14
star
20

sixarm_ruby_magic_number_type

SixArm.com » Ruby » MagicNumberType infers a data type from the data's leading bytes
Ruby
13
star
21

webservers

Webservers with implementations using many languages and tools
13
star
22

urlencode.sh

URL encode: shell function and command line script
Shell
12
star
23

port-to-process

port-to-process: Given a port number, look up any associated process and pid
Shell
11
star
24

git-tools

Git scripts for version control by SixArm.com
Shell
11
star
25

macos-defaults

Mac defaults: macOS system setup configuration script via default write
Shell
11
star
26

sixarm_css_holy_grail_layout_with_flexbox

SixArm.com » CSS » Holy Grail layout with flexbox
CSS
11
star
27

project-management-priority-score

Project management priority score for ranking goals, tasks, issues, etc.
10
star
28

data-for-geolocation

Data for geolocation, countries, cities, postal codes, etc. by SixArm.com
10
star
29

sixarm_ruby_email_address_validation

SixArm.com » Ruby » Email address validation using RFC 822
Ruby
10
star
30

uri-parser

Parse a URI or URL to its scheme, host, path, query, fragment, etc.
Shell
9
star
31

venn

venn: set operations with a command line shell script
Shell
9
star
32

sixarm_brew_install

SixArm.com » Brew install scripts for our various packages
Shell
9
star
33

sixarm_ruby_gemfile

SixArm.com » Ruby » Gemfile chock full of lots of gems and descriptions
Ruby
9
star
34

apt-tools

Apt scripts for system administration
Shell
8
star
35

sqlite-import-csv

SQLite shell script to import a CSV file
Shell
8
star
36

ssh-keygen-pro

ssh-keygen-pro: generate SSH keys using professional quality conventions
Shell
8
star
37

file-size

File size script that works on many operating systems
Shell
7
star
38

change-case

Change case of text using the command line: upper-case, lower-case, title-case, camel-case, snake-case, chain-case, token-case, slug-case
Shell
7
star
39

tmux-start

Start a tmux session with windows and keys suitable for scripting
Shell
7
star
40

vboxmanage-createvm

VirtualBox VBoxManage script to create a virtual machine for Ubuntu
Shell
7
star
41

software-programming-guide

Software Programming Guide: this book explains one topic per page, like a big glossary, easy wiki, quick encyclopedia, or summary notes. Edited by Joel Parker Henderson (@joelparkerhenderson).
Makefile
7
star
42

brew-install-favorites

Use the `brew` command to install our favorite pacakages and applications for macOS
Shell
6
star
43

firefox-optimize-sqlite-vacuum

Firefox script to optimize SQLite by using vacuum to delete stale data
Shell
6
star
44

git-rename-master-branch-to-main

Use git to rename the default branch from "master" to "main"
Shell
5
star
45

chown-chmod-me

Use `chown` and `chmod` to set access control to exactly my user and primary group
Shell
5
star
46

sixarm_nagios_plugins

SixArm.com » Nagios » Plugins for monitoring servers
Shell
5
star
47

passable

passable: password manager command line tool that's just good enough
Shell
5
star
48

sixarm_unix_installation_help

SixArm.com » Unix » Installation help for servers and desktops, esp. Debian and Ubuntu
Shell
5
star
49

gpg-decrypt

Use GPG to decrypt a file using our best settings
Shell
5
star
50

git-clone-favorites

git clone our favorite repositories to our favorite paths
Shell
5
star
51

safari-reset

Reset the macOS Safari web brower via terminal command line shell script
Shell
5
star
52

hostinfo-commands

hostinfo commands for macOS
Shell
4
star
53

log-file-cleaning

Log file cleaning script that deletes old files and logrotate files
Shell
4
star
54

sixarm_bash_config

SixArm.com → Bash shell → Bash configuration files
Shell
4
star
55

sixarm_brew_scripts

SixArm.com » Brew scripts for the Homebrew OS X package manager
Shell
4
star
56

sixarm_unix_etc_files

SixArm.com » Unix » /etc » /etc system configuration files, like /etc/profile
Shell
4
star
57

brew-cask-font-sync-to-system

Command to synchronize Homebrew fonts from Caskroom to /Library/Fonts
Shell
4
star
58

ievm

Internet Explorer virtual machine download scripts for http://modern.ie
Shell
4
star
59

kill-port

kill-port: kill all processes that are attached to a given port; this is POSIX shell command
Shell
4
star
60

pmset-commands

pmset commands for power management settings for macOS
Shell
4
star
61

sixarm-company-consulting-agreement

SixArm.com → Company consulting agreement
4
star
62

compaudit-fixer

Command `compaudit-fixer` that repairs file owners and permissions on zsh scripts
Shell
4
star
63

base64-decode-gpg-decrypt

base64-decode-gpg-decrypt: Unix command to do base64 decode then gpg decrypt
Shell
4
star
64

github-api-tools-with-python

GitHub API scripts
Python
4
star
65

sixarm_ruby_zid

SixArm.com » Ruby » ZID: Zen Identifier
Ruby
4
star
66

checkline-rust-crate

checkline is a Unix command line interface (CLI) terminal user interface (TUI) that prompts you to check each line of stdin, to pick each line to output to stdout
Rust
4
star
67

sixarm_git_ignore

SixArm.com » git » gitignore configuration files
3
star
68

urldecode.sh

URL decode: shell function and command line script
Shell
3
star
69

markline

markable line picker for stdin line input
Rust
3
star
70

sixarm_shell_random_scripts

SixArm.com → Shell → Random scripts to generate text
Shell
3
star
71

sixarm_rust_standard_echo_server

SixArm.com → Rust → standard → echo server
Rust
3
star
72

sixarm_aws_cli

Amazon Web Service (AWS) Command Line Interface (CLI) examples
Shell
3
star
73

sixarm_schema_org

SixArm » Schema.org Utilties
Ruby
3
star
74

mast-cell-help

Mast cell help: a guide book glossary about mast cell activation syndrome (MCAS) symptoms, diagnosis, treatments, and healthcare.
Svelte
3
star
75

sixarm-company-confidentiality-agreement

SixArm.com → Company confidentiality agreement (CA) a.k.a. non-disclosure agreement (NDA)
3
star
76

getoptsy

getoptsy: getopts alternative to parse command line arguments to long options, in POSIX, using custom code.
Shell
3
star
77

sixarm-virtualbox-scripts

SixArm VirtualBox scripts
Shell
3
star
78

data-mock-helpers

Data mock helpers for generating samples
3
star
79

sixarm_ssh_scripts

SixArm.com » SSH » Scripts for secure shell keys, hosts, fingerprints, etc.
Shell
3
star
80

openssl-encrypt

OpenSSL encrypt: use openssl to encrypt a file using our best symmetric settings
Shell
3
star
81

rm-rotated-files

Remove rotated log files: files that are compressed, or numbered, or datestamped, e.g. syslog.1, history.gz, etc.
Shell
3
star
82

sixarm_git_dot_files

SixArm.com → git → dot files for configuration
3
star
83

markdown-tools

SixArm.com » Markdown » Scripts for parsing markdown
Ruby
3
star
84

markdown-toc-generator

Markdown Table Of Contents generator script
Ruby
3
star
85

sixarm_postfix_checks

SixArm.com » Postfix » Checks for spam blocking
3
star
86

sixarm_ruby_markdown_table_of_contents

SixArm.com → Ruby → Markdown table of contents generator
Ruby
3
star
87

sixarm_ruby_rbac

SixArm.com » Ruby » RBAC: Role Based Access Control for users, roles, permissions, etc.
Ruby
3
star
88

rsvg-convert-svg-to-apple-xcode-icon-pixel-sizes

Use `rsvg` command to convert from a SVG image to Apple Xcode icon pixel sizes as PNG files
Shell
3
star
89

apt-install-favorites

Use the `apt-get` command to install our favorite packages for Debian, Ubuntu, Mint, etc.
Shell
3
star
90

unix-system-version-information

Unix system version information
Shell
3
star
91

html-span-data-chatgpt-prompt

HTML span data-chatgpt-prompt autocomplete via Python and OpenAI.com ChatGPT API
Python
2
star
92

boldcontacts-site-as-svelte

BoldContacts site implemented as SvelteKit
Svelte
2
star
93

sixarm_rust_actix_epoch

SixArm.com → Rust → Actix → Epoch → Show Unix epoch timestamp
Rust
2
star
94

git-mv-file-name-from-underscore-to-dash

git-mv-file-name-from-underscore-to-dash command to rename a file from "_" to "-"
Shell
2
star
95

postgresql-brew-macos-help

PostgreSQL brew macOS help
2
star
96

read-lines-into-rust-crate

file_into_string Rust crate to read lines of a text file into a string or vector of strings
Rust
2
star
97

sixarm_unicode_emoji

SixArm.com Unicode Emoji Examples
2
star
98

swagger-starter

Swagger Starter Kit for sharing API specifications
JavaScript
2
star
99

wipe-free-disk-space

wipe-free-disk-space: Unix command to secure erase all extra bytes on a drive
Shell
2
star
100

yaml-to-json

yaml-to-json: Unix command to convert YAML text to JSON text
Ruby
2
star