[branch]
    autosetupmerge = true

[commit]
    gpgsign = true
    ;verbose = true
[push]
    default = upstream

[rerere]
    enabled = true

[rebase]
    autosquash = true

[color]
    ui = auto

[color "branch"]
    current = yellow reverse
    local = yellow
    remote = green

[color "decorate"]
    remoteBranch = blue bold

[color "diff"]
    meta = yellow bold
    frag = magenta bold
    old = red bold
    new = green bold

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

[core]
    pager = less -R

[help]
    autocorrect = 1 #fucking magic!

#Kudos for (copied from):
#http://git-scm.com/book/en/Customizing-Git-Git-Configuration
#http://robots.thoughtbot.com/post/4747482956/streamline-your-git-workflow-with-aliases
#http://oli.jp/2012/git-powerup/#conclusion
#http://blog.blindgaenger.net/advanced_git_aliases.html
#https://gist.github.com/robmiller/6018582 (branch-name, publish, unpublish)

[apply]
	whitespace = nowarn


# URL shorthands

[url "git@github.com:"]
	insteadOf = "gh:"
	pushInsteadOf = "github:"
	pushInsteadOf = "https://github.com/"

[url "git://github.com/"]
	insteadOf = "github:"

[url "git@gist.github.com:"]
	insteadOf = "gst:"
	pushInsteadOf = "gist:"
	pushInsteadOf = "git://gist.github.com/"

[url "git://gist.github.com/"]
	insteadOf = "gist:"

[diff]
	# Detect copies as well as renames
	renames = copies

[diff "bin"]
	# Use `hexdump` to diff binary files
	textconv = hexdump -v -C


[alias]
########LAZY VERSIONS OF BASIC COMMANDS########

    co = checkout
    br = branch
    ci = commit
    st = status

########BETTER VERSIONS OF BASIC COMMANDS########

    purr = pull --rebase
    puff = pull --ff-only
    difff = diff --color-words #just words
    bbranch = branch -v
    branches = branch -avvl
    sth = stash -u
    unstage = reset HEAD --
    alias = !git config --list | grep 'alias\\.' | sed 's/alias\\.\\([^=]*\\)=\\(.*\\)/\\1 => \\2/' | grep -v 'alias'| awk 'BEGIN { FS = \"=>\" }{ printf(\"%-20s=>%s\\n\", $1,$2)}'|sort
    makegitrepo = !git init && git add . && git commit -m \"initial commit\"
    fpush = push --force-with-lease

    #BASIC HISTORY VIEWING

    hist = log --graph --date=relative \
        --format=format:'%C(auto)%h %C(bold blue)%an%C(auto)%d %C(green)%ad%C(reset)%n%w(80,8,8)%s'
    histfull = log --graph --date=relative --name-status \
        --format=format:'%C(auto)%h %C(bold blue)%an%C(auto)%d %C(green)%ad%C(reset)%n%w(80,8,8)%s%n'
    llog = log --pretty=format:'%C(yellow)%h %Cred%ad %Cblue%an%Cgreen%d %Creset%s' --date=iso
    changelog = log --pretty=format:'%Cgreen%d %Creset%s' --date=iso
    ls = log --pretty=format:'%C(yellow)%p..%h %C(white dim)%cd %<|(49,trunc)%an %C(reset)%s' --date=short --abbrev=8 --no-merges
    recent = for-each-ref --sort=-committerdate refs/heads/ --format='%(authordate:short) %(color:red)%(objectname:short) %(color:yellow)%(refname:short)%(color:reset) (%(color:green)%(committerdate:relative)%(color:reset))'

    #BASIC REPO INFORMATION

    whois = "!sh -c 'git log -i -1 --pretty=\"format::%an <%ae>\n\" --author=\"$1\"' -"
    whatis = show -s --pretty='tformat::%h (%s, %ad)' --date=short
    howmany = "!sh -c 'git log -a --pretty=oneline | wc -l'"
    howmanybywhom = shortlog -sn

    #WHAT WAS GOING ON, WHILE YOU WERE AWAY

    anychanges = !sh -c 'git fetch' && git log --oneline HEAD..origin/$1
    anychangesonmaster = !sh -c 'git fetch' && git log --oneline HEAD..origin/master
    whoischanging = !sh -c 'git shortlog HEAD..origin/$0'
    whoischangingmaster = !sh -c 'git shortlog HEAD..origin/master'

    #what branches you have on origin, with info on who is guilty and how long ago. Useful for gitflow and feature branches in general. Requires fetch up-front.
    showorigin = "!sh -c 'for branch in `git branch -r | grep -v HEAD`;do echo `git show -s --format=\"%Cred%ci %C(green)%h %C(yellow)%cr %C(magenta)%an %C(blue)\" $branch | head -n 1` \\\t$branch; done | sort -r'"

    #get remote branches
    trackallbranches = !sh -c "for branchname in `git branch -r `; do git branch --track $branchname; done"
    updateallbranches = !sh -c "for branchname in `git branch -r `; do git checkout $branchname ; git pull; done"

    #TAGS

    showtags = show-ref --tags
    pushtags = push --tags
    tagwithdate = !sh -c 'git tag "$0"_$(date "+%y-%m-%d_%H-%M-%S")'
    lasttag = describe --abbrev=0 --tags
    checkoutlasttag = !sh -c 'git checkout `git describe --abbrev=0 --tags`'
    # Pushes given tag to remote 'origin' repo (or the remote passed as the second parameter)
    publishtag = "!sh -c 'git push ${2:-origin} $1' -"
    # Removes given tag from remote 'origin' repo (or the remote passed as the second parameter)
    unpublishtag = "!sh -c 'git push ${2:-origin} :refs/tags/$1' -"

    #IGNORING

    # fix .gitignore
    fixgitignore = !git rm -r --cached . && git add . && git commit -m \"Just a .gitignore fix \"

    # Ignore files only locally
    hide = update-index --assume-unchanged
    unhide = update-index --no-assume-unchanged

    #OTHER
    #Finds a filename in the git repository. Gives absolute location (from the git root).
    find = !sh -c 'git ls-tree -r --name-only HEAD | grep --color $1' -

    #Deletes all branches that were safely merged into the master. All other are skipped (no worries).
    #on osx xargs does not have -r argument, so it fail. If you remove -r, it will run at least once, making this not safe operation
    cleanup = !git branch --merged=master | grep -Ev '^\\* | master$' | xargs -r git branch -d

    #Deletes orphaned remote branches (.git/refs/remotes/origin), clean up reflog and remove all untracked files
    cleanuplocal = !git remote prune origin && git gc && git clean -df

    # Check if any file in repo has whitespace errors
    # As described in http://peter.eisentraut.org/blog/2014/11/04/checking-whitespace-with-git/
    check-whitespace = !git diff-tree --check $(git hash-object -t tree /dev/null) HEAD

    # Check if any file in repo has windows line endings
    #Currently do not work as alias, works from comand line directly. There is a problem with \r
    check-eol = !git grep --files-with-matches $'\\r' HEAD

    #Jira tickets (from: http://blogs.atlassian.com/2014/08/whats-new-git-2-1/)
    issues = "!f() { : git log ; echo 'Printing issue keys'; git log --oneline $@ | egrep -o [A-Z]+-[0-9]+ | sort | uniq; }; f"
    #version for git below 2.1
    #issues = !sh -c 'git log --oneline $@ | egrep -o [A-Z]+-[0-9]+ | sort | uniq' -

    # Gets the current branch name (not so useful in itself, but used in other aliases)
    branch-name = "!git rev-parse --abbrev-ref HEAD"
    # Pushes the current branch to the remote "origin" (or the remote passed as the parameter) and set it to track the upstream branch
    publish = "!sh -c 'git push -u ${1:-origin} $(git branch-name)' -"
    # Deletes the remote version of the current branch from the remote "origin" (or the remote passed as the parameter)
    unpublish = "!sh -c 'set -e; git push ${1:-origin} :$(git branch-name);git branch --unset-upstream $(git branch-name)' -"

    # Fetch PR from GitHub by number/id
    fetchpr = "!sh -c 'git fetch origin pull/$0/head:pr/$0'"

    #add all, commit with message and push to remote
    apm = "!f() { git add --all && git commit -m \"$@\" && git push; }; f"


###################! Git Kurwa!####################
    drzewokurwa = log --graph --date=relative \
        --format=format:'%C(auto)%h %C(bold blue)%an%C(auto)%d %C(green)%ad%C(reset)%n%w(80,8,8)%s'
    duzedrzewokurwa= log --graph --date=relative --name-status \
        --format=format:'%C(auto)%h %C(bold blue)%an%C(auto)%d %C(green)%ad%C(reset)%n%w(80,8,8)%s%n'
    komitykurwa = log --pretty=format:'%C(yellow)%h %Cred%ad %Cblue%an%Cgreen%d %Creset%s' --date=iso

    ktotokurwa = "!sh -c 'git log -i -1 --pretty=\"format::%an <%ae>\n\" --author=\"$1\"' -"
    cotokurwa = show -s --pretty='tformat::%h (%s, %ad)' --date=short

    cotamkurwa = !sh -c 'git fetch' && git log --oneline HEAD..origin/$1
    cotammistrzukurwa = !sh -c 'git fetch' && git log --oneline HEAD..origin/master
    ktotamkurwa = !sh -c 'git shortlog HEAD..origin/$0'
    ktotammistrzukurwa = !sh -c 'git shortlog HEAD..origin/master'
    tagikurwa = show-ref --tags
    pchajtagikurwa = push --tags
    tagujzdatakurwa = !sh -c 'git tag "$0"_$(date "+%y-%m-%d_%H-%M-%S")'
    wyjebtag = !sh -c 'git tag -d "$0"'
    wyjebtagwchuj = !sh -c 'git tag -d "$0" && git push --delete origin tag "$0"'

    pojebalosiekurwa = reset --hard

    ktonajebalkurwa = blame

    kurwa = status
    cokurwa = status
    cojestkurwa = diff
    howcanikurwa = help
    nabokkurwa = stash
    zbokukurwa = stash apply
    sprzatajkurwa = clean
    sprzatajwszystkokurwa = !sh -c 'git clean -x' && git reset --hard
    wyjebzrobionekurwa = !sh -c 'git branch --merged' | grep -v "\\*" | grep -v master | grep -v dev | xargs -n 1 git branch -d
    majonez = !sh -c 'branch="$(git rev-parse --abbrev-ref HEAD)" && git checkout master && git pull && git branch -d "$branch"'

    dodajkurwa = add
    takkurwa = commit
    sciagajkurwa = pull
    sciagajtegokurwa = !sh -c 'git pull origin $(git rev-parse --abbrev-ref HEAD)'
    dalejkurwa = push
    dalejnowociotokurwa = push -u origin master
    pchajkurwa = push
    pchajkurwayolo = push --force
    sorrykurwa = commit --amend -m
    spierdolwszystko = merge

    cofnijwchuj = reset HEAD~100
    wypierdolwchuj = reset HEAD~100 --hard
    acomitamkurwa = push origin --force
    walictokurwa = rm .* -rF

    palisiekurwa = !sh -c 'git add . && git commit -m \"palilo sie\" --no-gpg-sign --no-verify && git push --force && echo \"Ok, now RUN!\"'



################################################## PERSONAL DATA ###############################################
[user]
	name = VectorKappa
	email = piotrpatalong@gmail.com
	signingKey = 04EA77421E7CC22ADE23A06932DCE8467E7FBD4F
[mergetool]
	keepBackup = true
[init]
	defaultBranch = main
[filter "lfs"]
	clean = git-lfs clean -- %f
	smudge = git-lfs smudge -- %f
	process = git-lfs filter-process
	required = true
