Skip to content

Instantly share code, notes, and snippets.

@nemoinho
Last active May 5, 2021 19:11
Show Gist options
  • Save nemoinho/389246642f16b5e4e9b7adb537f7f558 to your computer and use it in GitHub Desktop.
Save nemoinho/389246642f16b5e4e9b7adb537f7f558 to your computer and use it in GitHub Desktop.
git configuration
[core]
# Use vim as commit-message editor
editor = vim
# Don't wrap lines on paged views such as diff or log
page = less -S
[diff]
# Use histogram to generate more readable diffs
algorithm = histogram
[pull]
# prefer to rebase local branches on remote changes instead of merging
rebase = true
[alias]
# Show all configured alias
alias = config --get-regexp ^alias\\.
# Manipulate the last commit
amend = commit --amend
# Just add any additional change to the last commit and push it
ash = "!git add .; git cane; git fush"
# Show all authors and their commit count in descending order
authors = "!git log --format='%aN <%aE>' | awk '{arr[$0]++} END{for (i in arr){printf \"%6s %s\\n\", arr[i], i;}}' | sort -rn"
# Checkout a new branch from the current HEAD and use it instantly, e.g. git bc my-new-local-branch
bc = checkout -b
# Reset ALL changed files, even new and deleted, similiar but much faster to `rm -rf * && git reset --hard HEAD`
bust = "!git restore --staged .; git co -- .; git clean -fd"
# Shortcut to change last commit without changing the commit-message
cane = commit --amend --no-edit
# Same like bc and just a help to prevent typos
cb = checkout -b
# Just a convenience alias for the first commit of a new project
cf = commit --allow-empty -m 'Initial commit'
# Shortcut for checkout, we are all lazy
co = checkout
# Show the changes which will be commited
dc = diff --cached
# Fetch all remote-changes, but don't merge local branches!
fa = fetch --all
# Mark a change as a fixup to a given commit, e.g. `git fix HEAD~2`, see git commit --help
fix = commit --fixup
# Fetch all remote-changes from origin, but don't merge local branches!
fo = fetch origin
# Perform a push with force but only if there are no remote changes which we don't know already!
fush = push --force-with-lease
# Use vimdiff to view current changes
gt = difftool --tool=vimdiff -y
# Sometimes you want to ignore files from git, but can't list them in .gitignore
# Manually ignored files are risky! Try always to use stash or commit instead!
ignore = update-index --assume-unchanged
# Bring manually ignored files back on track
ignorenot = update-index --no-assume-unchanged
# Show a list of manually ignored files
ignoreshow = ls-files -v | grep '^h'
# Just show a verbose log of the last 7 commits
last = log -7 --color --graph HEAD
# Show a graph of all changes within the repository
lg = log --graph --all --date-order --format='%C(yellow)%h %C(bold red)%d %Creset%s %Cgreen(%ar) %C(bold blue)%an <%ae>'
# Like 'lg' but with a ISO 8601-like timestamp
lgi = log --graph --all --date-order --format='%C(yellow)%h %C(bold red)%d %Creset%s %Cgreen(%ai) %C(bold blue)%an <%ae>'
# Show a graph of only the current branch down to the development branch
lgb = log --graph --date-order --format='%C(yellow)%h %C(bold red)%d %Creset%s %Cgreen(%cr) %C(bold blue)%an <%ae>'
# Reset the commiter inside of a rebase-step to the current user
# Danger operation and only meaningful inside a rebase-process
mail-reset = "!bash -c 'export GIT_AUTHOR_DATE=$(git log -1 --pretty=format:%ad); export GIT_COMMITTER_DATE=$GIT_AUTHOR_DATE; git commit --amend --no-edit --author=\"$(git config user.name) <$(git config user.email)>\"; unset GIT_AUTHOR_DATE; unset GIT_COMMITTER_DATE'"
# Open interactive rebase-console to given commit, e.g. `git ri HEAD~3`
ri = rebase -i
# Apply fixup and squach commits, see git commit --help
ria = rebase -i --autosquash
# Just save all as it is and add a stupid commit message to it
save = "!git add .; git commit -m save"
# Mark a change as a squach to a given commit similiar to `fix`
squ = commit --squash
# We are lazy and don't want to type status all the time
st = status
# Dispose all old branches which are already deleted remote, except of master and develop!
trash = "!git branch --merged | egrep -v \"(^\\*|master|develop)\" | xargs git branch -d; git remote prune origin"
# Unstage added files
unstage = reset HEAD
[include]
path = local/config
# Example for this file
[user]
name = John Doe
email = [email protected]
# Created by https://www.gitignore.io/api/vim,jetbrains
# Edit at https://www.gitignore.io/?templates=vim,jetbrains
### JetBrains ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
### JetBrains Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr
# Sonarlint plugin
.idea/**/sonarlint/
# SonarQube Plugin
.idea/**/sonarIssues.xml
# Markdown Navigator plugin
.idea/**/markdown-navigator.xml
.idea/**/markdown-navigator/
### Vim ###
# Swap
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]
# Session
Session.vim
Sessionx.vim
# Temporary
.netrwhist
*~
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~
# Coc configuration directory
.vim
# End of https://www.gitignore.io/api/vim,jetbrains
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment