{"id":13567562,"url":"https://github.com/SixArm/gitconfig-settings","last_synced_at":"2025-04-04T01:32:22.098Z","repository":{"id":1361076,"uuid":"1309870","full_name":"SixArm/gitconfig-settings","owner":"SixArm","description":"gitconfig setttings, files, aliases, colors, branches, etc.","archived":false,"fork":false,"pushed_at":"2023-09-15T19:21:39.000Z","size":111,"stargazers_count":135,"open_issues_count":0,"forks_count":26,"subscribers_count":7,"default_branch":"main","last_synced_at":"2024-05-14T19:45:01.256Z","etag":null,"topics":["git","gitalias","gitconfig","iac"],"latest_commit_sha":null,"homepage":"http://sixarm.com","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"ngerakines/erlang_facebook","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SixArm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null}},"created_at":"2011-01-30T20:00:17.000Z","updated_at":"2024-05-09T12:00:24.000Z","dependencies_parsed_at":"2022-08-16T13:10:56.265Z","dependency_job_id":"c1db4510-9d75-4cd9-9b6c-0eeadb97d94e","html_url":"https://github.com/SixArm/gitconfig-settings","commit_stats":{"total_commits":128,"total_committers":6,"mean_commits":"21.333333333333332","dds":0.421875,"last_synced_commit":"faa8eeea06135f4666699034a7cfeeb9e092a23c"},"previous_names":["sixarm/sixarm_git_gitconfig"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SixArm%2Fgitconfig-settings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SixArm%2Fgitconfig-settings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SixArm%2Fgitconfig-settings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SixArm%2Fgitconfig-settings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SixArm","download_url":"https://codeload.github.com/SixArm/gitconfig-settings/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247107816,"owners_count":20884793,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["git","gitalias","gitconfig","iac"],"created_at":"2024-08-01T13:02:34.817Z","updated_at":"2025-04-04T01:32:17.079Z","avatar_url":"https://github.com/SixArm.png","language":"Shell","funding_links":[],"categories":["Shell"],"sub_categories":[],"readme":"# gitconfig settings\n\nGit configuration settings, files, aliases, branches, merges, syntax coloring, merges, credentials, and more.\n\nExamples:\n\n  * Nicknames such as `git s` doing `git status`\n  * Workflows such as `git rbi` doing a rebase, interactively, on unpushed commits.\n  * Helpers such as `git optimize` doing a prune and repack.\n  \nFor the complete list, see the files in the `gitconfig.d` directory.\n\n\n## Install\n\nInstall for novices:\n\n  1. Get these files:\n\n        git clone https://github.com/SixArm/sixarm_git_gitconfig.git\n\n  2. Create your own personal `.gitconfig` file, or edit your existing file, such as:\n\n        edit ~/.gitconfig\n\n  3. Add these lines:\n\n        [include]\n           path = sixarm_git_gitconfig/gitconfig\n\nInstall for experts:\n\n  1. If you want full control, then you can copy any of these files and edit them as you like.\n\n  2. The `alias.txt` file has the bulk of the items - start with that file.\n\n  3. If you want to include some files, but not others, then you can use this syntax:\n\n        [include]\n           path = sixarm_git_gitconfig/gitconfig.d/alias.txt\n           path = sixarm_git_gitconfig/gitconfig.d/color.txt\n\nInstall for specific operating systems:\n\n  1. If your system is OSX, and you want to enable the keychain credential manager, then add this:\n\n        [include]\n           path = sixarm_git_gitconfig/gitconfig.d/specific-to-osx.txt\n\n  2. If your system is Windows, and you want to enable the system credential manager, then add this:\n\n        [include]\n           path = sixarm_git_gitconfig/gitconfig.d/specific-to-windows.txt\n\n\n## Alias shortcuts\n\nOne letter shortcuts are for fast typing:\n\n    a = add\n    b = branch\n    c = commit\n    d = diff\n    f = fetch\n    g = grep\n    l = log\n    m = merge\n    o = checkout\n    p = pull\n    r = remote\n    s = status\n    w = whatchanged\n\nThere are many two letter shortcuts for popular commands and options, such as these:\n\n    ap = add --patch\n    be = branch --edit-description\n    ci = commit --interactive\n    ds = diff --staged\n    lg = log --graph\n\tss = status --short\n\nTo see the complete list, please see the files in the `gitconfig.d` directory.\n\n\n## Favorites\n\nHere are some of our alias favorites that we use often:\n\nGet everything new:\n\n    get = !git pull --rebase \u0026\u0026 git submodule update --init --recursive\n\nRebase interactive on our unpushed commits:\n\n    rbi = !git rebase --interactive @{u}\n\nSummarize changes for a daily standup meeting:\n\n    log-standup = !git log --since yesterday --pretty=short --author `git config user.email`\n\nFind text in any commit ever:\n\n    grep-all = !\"git rev-list --all | xargs git grep '$1'\"\n\n\n## Publishing\n\nHere are a couple our favorites for publishing. For the complete list, see `gitconfig.d/alias.txt`.\n\nPublish the current branch by pushing and tracking:\n\n    publish = \"!git push -u origin $(git branch-name)\"\n\nUnpublish the current branch by deleting the remote branch:\n\n    unpublish = \"!git push origin :$(git branch-name)\"\n\n\n\n## Cleaning\n\nHere are some of our favorites; for the complete list, see `gitconfig.d`.\n\nPrune stale items:\n\n    pruner = !git prune --expire=now; git reflog expire --expire-unreachable=now --rewrite --all\n\nRepack the way Linus recommends:\n\n    repacker = !git repack -a -d -f --depth=300 --window=300 --window-memory=1g\n\nDelete all branches that have been merged into master:\n\n    master-cleanse = !\"git checkout master \u0026\u0026 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\u003e\u00261 | grep --colour=never 'deleted'\"\n\n\n## Feature Flow\n\nAlias configuration for our feature flow. For details, see `gitconfig.d/alias-for-feature-flow.txt`.\n\nCreate a new feature branch:\n\n    feature-start = '!branch=$1; git checkout master; git pull; git checkout -b \"$branch\" master'\n\nUpdate the feature branch:\n\n    feature-update = '!branch=$(git branch-name); git checkout master; git pull; git checkout \"$branch\"; git rebase master'\n\nShare the feature branch:\n\n    feature-share = '!branch=$(git branch-name); git push -u origin \"$branch\"'\n\nIf 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.\n\n\n## User personalization\n\nIf you use the `user.txt` file, you will want to personalize it:\n\n    [user]\n      email = alice@example.com\n      name = Alice Anderson\n\n\n## GitHub personalization\n\nIf you use GitHub and the `github.txt` file, you will want to personalize it:\n\n    [github]\n      user = alice\n      token = alice-token\n\n\n## Customization\n\nYou can customize any of the file items by editing the file as you like.\n\nYou can also customize any of the file items by adding your own item later in your own gitconfig file.\n\nFor example you can include our aliases then customize \"git l\" with your own definition:\n\n    [include]\n       path = ~/.gitconfig.d/alias.txt\n\n    [alias]\n       l = log --graph --oneline\n\n\n## Format\n\nTo use better pretty formatting:\n\n    [format]\n      pretty = \"%H %ci %ce %ae %d %s\"\n\n\n## Status\n\nIf you like terse status messages:\n\n    [alias]\n      s = status -sb\n\n## Log\n\nIf you like log summaries:\n\n    [alias]\n      l = log --graph --oneline\n\n\n## Meld merge tool\n\nWe like using the `meld` mergetool because it is powerful and can use three windows for comparisons.\n\nThis repo includes a script for running `meld` with three windows.\n\nTo use meld with three windows, put the script on your path, for example:\n\n    cp bin/meld-with-three-windows /usr/local/bin\n\n\n## Most pager\n\nIf you prefer using `most` as a pager:\n\n    [core]\n      pager = most\n\nTo get `most`, do `brew install most` on OSX, or `apt-get install most` on Ubuntu, etc.\n\n\n## Suggestion for branch auto setup merge\n\nWe tell git-branch and git-checkout to setup new branches so that git-pull\nwill appropriately merge from that remote branch.\n\n    git config --global branch.autosetupmerge true\n\nIf 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\".\n\n\n## Suggestion for tab completion\n\nTo install git tab completion, we go to the git source code directory then run:\n\n    echo \"source ./contrib/completion/git-completion.bash\" \u003e\u003e /etc/bash.bashrc\n\n\n## Suggestion for git GUI apps\n\nRead http://git.or.cz/gitwiki/InterfacesFrontendsAndTools\n\nOur favorite open source free GUI for Ubuntu is http://cola.tuxfamily.org/\n\n\n  \n\n## Stash\n\nA 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.\n\n  ~~~gitconfig\n  git config --global stash.showPatch true\n  ~~~\n\n\n## Autostash\n\nAutomatically stash and unstash the working directory before and after rebases. This makes it possible to rebase with changes in the repo.\n\n  ~~~gitconfig\n  git config --global rebase.autostash true\n  ~~~\n\n\n## Decorate\n\nAlways decorate `git log`.\n\n  ~~~gitconfig\n  git config --global log.decorate full\n  ~~~  \n  \n\n## Autosquash\n\nSetting autosquash enables it by default for all interactive rebases. When committing you can specify `--squash=\u003ccommit\u003e` or `--fixup=\u003ccommit\u003e`, then `git rebase -i --autosquash` will automatically move and mark the relevant commits in your rebase queue. \n\n  ~~~gitconfig\n  rebase.autoSquash true\n  ~~~\n\n\n## User config\n\nWe 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.\n\n  ~~~gitconfig\n  user.useConfigOnly true\n  ~~~\n\nThe `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.\n\n\n## Commit intent\n\nWhen 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.\n\n  ~~~gitconfig\n  alias.original \"!git show $(cat .git/rebase-apply/original-commit)\"\n  ~~~\n\n\n## Recursive git\n\nIf you accidentally type `git git foo`, then correct it.\n\n  ~~~gitconfig\n  alias.git \"!git\"\n  ~~~\n\n## Merge tool\n\n    merge.tool \u003cyourtool\u003e\n\nWill automatically use the specified tool when invoking \"git mergetool\", if you like external utilities to perform merges or conflict resolution (\n\nTry these: emerge, kdiff3, araxis, vimdiff3, meld. The list of builtin tool support is accessible via \"git mergetool --tool-help\".\n\n\n## FF\n\nThis has saved me:\n\n  ~~~gitconfig\n  git config  --global pull.ff only\n  ~~~\n\nI 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.\n\nIf you set this config, and a fast-forward pull is not possible, here is what git does:\n\n  ~~~shell\n  $ git pull\n  fatal: Not possible to fast-forward, aborting.\n  ~~~\n\n\n## Signing vs. fast forward\n\nIf 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. \n\nTheoretically 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.\n\nIn a shared repository, I prefer creating \"useless\" merge commits to changing other peoples signatures.\n\n\n## diff-so-fancy  \n\nI really like diff-so-fancy [1] highlighter as a pager and to review diffs. Previously discussed here on HN here: [2]\n\n  * https://github.com/so-fancy/diff-so-fancy\n\n  * https://news.ycombinator.com/item?id=11057421\n\n\n## force with lease\n\nIf we are stuck and we must push with force, then we use this:\n\n    git push --force-with-lease\n\nInstead of:\n\n    git push -f\n\nThe 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.\n\nIn our opinion, this should be the default.\n\n\n## Log format\n\nLog format with condensed view, graph, and tags:\n\n  ~~~gitalias\n  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\n  ~~~\n\nLog 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:\n\n  ~~~gitalias\n  lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen%cn%Creset %Cblue(%cr)%Creset' --abbrev-commit --date=relative\n  ~~~\n\nAnother:\n\n  ~~~gitalias\n  lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)\u003c%an\u003e%Creset' --abbrev-commit\n  ~~~\n\n\n## Yellow\n\nOne 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:\n\n  ~~~gitconfig\n  [color \"status\"]\n    untracked = red\n    changed = yellow\n    added = green\n  ~~~\n\n\n## Vim diff\n\nI'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. \n\nAlso, I really love diffing entire trees in one vim session using the DirDiff plugin (https://github.com/will133/vim-dirdiff).\n\nHere's how I wire it into my .gitconfig, which gets me the alias \"git dirdiff\":\n\n  ~~~gitconfig\n  [difftool \"default-difftool\"]\n    cmd = gvim -f '+next' '+execute \\\"DirDiff\\\" argv(0) argv(1)' $LOCAL $REMOTE\n\n  [difftool]\n    prompt = false\n\n  [alias]\n    dirdiff = difftool --dir-diff\n  ~~\n\nI 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.\n\nAlso, 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.\n\nHere's my diff-related .vimrc hackage:\n\n  ~~~vimrc\n  if \u0026diff\n    set lines=60 columns=184\n    set foldminlines=99999\n    set nomodifiable\n    set nowrite\n  endif\n  ~~~\nreply\n  \n\n## tmux\n\nI 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:\n\n  ~~~shell\n  # A nice shell prompt for inside git repostories\n  # Shows a short status of the repository in the prompt\n  # Adds an alias `g=git` and makes autocomplete work\n  gitprompt() {\n\n      __color_bold_blue='\\[$(tput bold)\\]\\[$(tput setaf 4)\\]'\n      __color_white='\\[$(tput sgr0)\\]'\n\n      export GIT_PS1_SHOWDIRTYSTATE=true;\n      export GIT_PS1_SHOWSTASHSTATE=true;\n      export GIT_PS1_SHOWUNTRACKEDFILES=true;\n      export GIT_PS1_SHOWUPSTREAM=\"auto\";\n      export GIT_PS1_SHOWCOLORHINTS=true;\n      . /usr/lib/git-core/git-sh-prompt;\n\n      local ps1_start=\"$__color_bold_blue\\w\"\n      local ps1_end=\"$__color_bold_blue \\\\$ $__color_white\"\n      local git_string=\" (%s$__color_bold_blue)\"\n\n      export PROMPT_COMMAND=\"__git_ps1 \\\"$ps1_start\\\" \\\"$ps1_end\\\" \\\"$git_string\\\"\"\n\n      # Short alias for git stuff\n      alias g=git\n\n      # Make autocomplete also work fo the `g` alias\n      eval $(complete -p git | sed 's/git$/g/g')\n\n  }\n  ~~~\n\nSo I have this in my `.bashrc` and when I want my bash to get a handy Git prompt I type `gitprompt`.\n\nYou 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:\n\n* https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh\n\n\n## fsckobjects\n  \nDon'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.\n\nThe 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).\n\nGit doesn't check validity of commit hashes by default.\n\n\n## Merge/diff tools\n\n* The merge/diff tool I use is p4diff, which comes with P4V (Perforce visual client) and is free.\n\n\n## tig\n\nTo explore the git log, I use tig. https://github.com/jonas/tig\n\nIt is a curses interface to git. Screenshot: https://atlassianblog.wpengine.com/wp-content/uploads/tig-2....\n\n\n## GPG with keybase.io to sign commits\n\nShameless plug. I published a little guide some months ago, on how to use GPG with keybase.io to sign commits.\n\nLink: https://github.com/pstadler/keybase-gpg-github\n\nDiscussion on HN: https://news.ycombinator.com/item?id=12289481\n\n\n## More\n\nFor more git config ideas, and for credit for many of the aliases here, please see these excelent resources:\n\n  * \u003chttps://git.wiki.kernel.org/index.php/Aliases\u003e\n  * \u003chttp://stackoverflow.com/questions/267761/what-does-your-gitconfig-contain\u003e\n  * \u003chttp://superuser.com/questions/169695/what-are-your-favorite-git-aliases\u003e\n  * \u003chttp://stackoverflow.com/questions/1309430/how-to-embed-bash-script-directly-inside-a-git-alias\u003e\n  * \u003chttp://code.joejag.com/2013/everyday-git-aliases/\u003e\n  * \u003chttp://blog.apiaxle.com/post/handy-git-tips-to-stop-you-getting-fired/\u003e\n  * \u003chttps://ochronus.com/git-tips-from-the-trenches/\u003e\n  * \u003chttp://mislav.uniqpath.com/2010/07/git-tips/\u003e\n  * \u003chttps://ochronus.com/git-tips-from-the-trenches/\u003e\n  * \u003chttp://mislav.uniqpath.com/2010/07/git-tips/\u003e\n  * \u003chttps://blog.scottnonnenberg.com/better-git-configuration/\u003e\n  * \u003chttps://news.ycombinator.com/item?id=14045787\u003e\n\n\n## Thanks\n\n  * [Joel Parker Henderson](https://github.com/joelparkerhenderson)\n  * [Bill Lazar](https://github.com/billsaysthis)\n  * [Joe Nelson](https://github.com/begriffs)\n  * [Scott Lindsay](http://stackoverflow.com/users/167384/scott-lindsay)\n  * [baudtack](http://baudtack.com)\n  * [Ruben Verborgh](http://ruben.verborgh.org)\n  * [Rob Kennedy](http://cs.wisc.edu/~rkennedy)\n  * [Corey Haines](http://coreyhaines.com/)\n  * [Mislav Marohnić](http://mislav.uniqpath.com/)\n  * [Gary Bernhardt](http://destroyallsoftware.com)\n  * [Joe Nelson](http://begriffs.com)\n  * [Rob Miller](https://github.com/robmiller)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSixArm%2Fgitconfig-settings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSixArm%2Fgitconfig-settings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSixArm%2Fgitconfig-settings/lists"}