Skip to content

Instantly share code, notes, and snippets.

@LwServices
Created April 19, 2023 18:59
Show Gist options
  • Save LwServices/0e70c511f075c091adf0c022f1c336e5 to your computer and use it in GitHub Desktop.
Save LwServices/0e70c511f075c091adf0c022f1c336e5 to your computer and use it in GitHub Desktop.
.gitconfig
[user]
name = Lw
email = w@gmail.com
username = lws
[credential]
helper = manager-core
[core]
editor = nano
autocrlf = true
#pager = \"C:/Program Files/Notepad++/notepad++.exe\" "$1"
#whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
#excludesfile = ~/.gitignore
[color]
# Enable colors in color-supporting terminals
ui = auto
#[web]
# browser = google-chrome
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
[diff]
tool = vsdiffmerge
guitool = winmerge
[difftool]
prompt = false
[difftool "winmerge"]
name = WinMerge
path = C:/Program Files/WinMerge/winmergeu.exe
cmd = \"C:/Program Files/WinMerge/winmergeu.exe\" -e -u -dl \"Local ( A ): $LOCAL\" -dr \"Remote ( B ): $REMOTE\" \"$LOCAL\" \"$REMOTE\"
#[difftool "wm"]
# name = WinMergeScript
# # "$PROGRAMFILES/WinMerge/WinMergeU.exe" -e -u -dl "Local" -dr "Remote" "$1" "$2"
# cmd = winmerge.sh \"$LOCAL\" \"$REMOTE\"
[difftool "vsdiffmerge"]
#cmd = \"C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/CommonExtensions/Microsoft/TeamFoundation/Team Explorer/vsDiffMerge.exe\" \"$LOCAL\" \"$REMOTE\" //t
cmd = \"C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\Common7\\IDE\\CommonExtensions\\Microsoft\\TeamFoundation\\Team Explorer\\vsdiffmerge.exe\" \"$LOCAL\" \"$REMOTE\" //t
keepbackup = false
trustexistcode = true
[difftool "codecompare"]
cmd = \"C:\\Program Files\\Devart\\Code Compare\\CodeCompare.exe\" -W \"$LOCAL\" \"$REMOTE\"
renames = true
[merge]
tool = codecompare
[mergetool]
prompt = false
keepbackup = false
[mergetool "winmerge"]
#https://manual.winmerge.org/en/Command_line.html
name = WinMerge
path = C:/Program Files/WinMerge/winmergeu.exe
cmd = \"C:/Program Files/WinMerge/winmergeu.exe\" -e -u -wl -wr -fm -dl \"Mine: $LOCAL\" -dm \"Merged: $BASE\" -dr \"Theirs: $REMOTE\" \"$LOCAL\" \"$BASE\" \"$REMOTE\" -o \"$MERGED\"
keepbackup = false
trustexistcode = true
[mergetool "vsdiffmerge"]
#cmd = \"C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/CommonExtensions/Microsoft/TeamFoundation/Team Explorer/vsDiffMerge.exe\" \"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\" //m
cmd = \"C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\Common7\\IDE\\CommonExtensions\\Microsoft\\TeamFoundation\\Team Explorer\\vsdiffmerge.exe\" \"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\" //m
keepbackup = false
trustexistcode = true
[mergetool "codecompare"]
#https://www.devart.com/codecompare/integration_git.html
cmd = \"C:\\Program Files\\Devart\\Code Compare\\CodeMerge.exe\" -MF \"$LOCAL\" -TF \"$REMOTE\" -BF \"$BASE\" -RF \"$MERGED\"
trustExitCode = true
[pull]
rebase = false
[fetch]
prune = false
[rebase]
autoStash = false
[alias]
# http://blog.gitora.com/tag/documentation/
# https://www.atlassian.com/blog/git/advanced-git-aliases
## Archive
#
# git ls-files | tar Tzcf - archive.tgz
# git ls-files | xargs -d '\n' zip repository.zip
# git ls-files -s
# git ls-files | xargs -d '\n' md5sum >..\hash.txt
# $1 = Branch
# $2 = Zip File Name
# see: https://stackoverflow.com/questions/23115777/git-archive-with-unstaged-changes
# git archive --names-only $1 | xargs zip $2
# https://www.techiedelight.com/determine-current-branch-name-git/
# https://stackoverflow.com/questions/37157669/using-variables-in-git-alias
# http://alblue.bandlem.com/2011/09/git-tip-of-week-git-archive.html
#
#az = archive --format=zip --output=../here2.zip master
az = "!makearch () {sh OUTPUTFILEPATH=`!git branch --show-current`; git archive --format=zip --output=../name.zip HEAD; }; makearch"
med = "!f() {BRANCH=´git symbolic-ref --short HEAD´; }; f"
#git archive --format=zip --output ../nlmk_patch2.zip NLMK_V202005053 $(git diff --name-only NLMK_V2020.05052)
aa = "!git archive --format=zip --output ../patch.zip $1 $(git diff --name-only $2)"
# undo last commit
# use --hard if you don't care about keeping the changes you made
uh = reset --hard HEAD^
# undo last commit
# use --soft if you want to keep your changes
us = reset --soft HEAD^
##branches
# local branches
bl = !git branch -vv
#checkout
co = checkout
#new_empty = !git checkout --orphan $1
# dann
#remove_all = git rm -rf .
#branch with hash and comment
br = branch -v
#clean -f (files) -d (directories) -X (ignored)
cf = clean -f
cd = clean -f -d
cx = clean -f -X
#show
sf = show --name-status
# https://stackoverflow.com/questions/11168141/find-which-commit-is-currently-checked-out-in-git
so = show --oneline -s
#Show Winmerge https://stackoverflow.com/questions/17558221/how-can-i-view-the-output-of-git-show-in-a-diff-viewer-like-meld-kdiff3-etc
sw = "!showfile () { rev=${1:-HEAD}; git difftool --tool=winmerge $rev~1 $rev; }; showfile $1"
sf = "!showci () { rev=${1:-HEAD}; git diff --name-status $rev~1 $rev; }; showci $1"
sd = "!showci () { rev=${1:-HEAD}; git diff $rev~1 $rev; }; showci $1"
#sn = "!showci () { show $1 > /c/temp/temp.txt && \"C:/Program Files/Notepad++/notepad++.exe\" /c/temp/temp.txt }; showci $1"
#sn = "!showci () { git show $1 > /c/temp/temp1.txt && \"C:/Program Files/Notepad++/notepad++.exe\" /c/temp/temp1.txt ; }; showci $1"
#sx = "!showci () { git show $1:$3 > /c/temp/temp_$1.txt && \"C:/Program Files/Notepad++/notepad++.exe\" /c/temp/temp_$1.txt ; }; showci $1 $2 $3"
sn = "!showci () { filename=$(echo $3 | sed 's:.*/::'); git show $1:$3 > /c/temp/temp_$1_$filename && \"C:/Program Files/Notepad++/notepad++.exe\" /c/temp/temp_$1_$filename; }; showci $1 $2 $3"
#status
st = status
#git config
cfg = !cat .git/config
spp = status --porcelain
#push with tags
pt = push --tags
#pull
#https://stackoverflow.com/questions/3497123/run-git-pull-over-all-subdirectories
#ls | xargs -I{} git -C {} pull
#from other repo
# https://www.educative.io/edpresso/the-fatal-refusing-to-merge-unrelated-histories-git-error
# git pull origin master --allow-unrelated-histories
#https://stackoverflow.com/questions/1709177/git-pull-a-certain-branch-from-github
#https://stackoverflow.com/questions/13716658/how-to-delete-all-commit-history-in-github
#log
# https://stackoverflow.com/questions/15458237/git-pretty-format-colors
lm = log --color --author=lech-jedrzej.wiecierzynski@sms-group.com --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'
#lg = log --color --oneline --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'
lg = log --color --oneline --date=format:'%d.%m.%Y %H:%M' --pretty=format:'%C(bold red)%h%Creset %Cgreen%ad%Creset%<(15,trunc) %C(bold blue)%cN%Creset%C(ul yellow)%d%Creset %s %Cgreen(%cr)'
lx = log --oneline --date=format:'%Y-%m-%d' --pretty=format:'%ad%<(25,trunc) %cN%d %s' --merges --first-parent
#git log --oneline --date=format:'%Y-%m-%d' --pretty=format:'%ad -%<(25,trunc) %cN%d %s' --merges --first-parent -30 | sed 's/Merge branch//g' | sed "s/'BF./Bugfix /g" | sed "s/'FT./Feature /g" | sed "s/' into 'PJ.XFrame_dev'//g" | sed "s/.*'JC.*//"
#lf = log --color --oneline --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' -p --name-status
lf = log --color --oneline --date=format:'%d.%m.%Y %H:%M' --pretty=format:'%C(bold red)%h%Creset %Cgreen%ad%Creset%<(15,trunc) %C(bold blue)%cN%Creset%C(ul yellow)%d%Creset %s %Cgreen(%cr)' -p --name-status
#shortlog
sl = shortlog
#graph
gr = log --color --graph --oneline
#gl = log --color --graph --pretty=format:'%>(10)%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
gf = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit -p --name-status
gl = log --graph --abbrev-commit --decorate=no --date=format:'%d.%m.%Y %H:%M' --format=format:'%C(bold red)%>|(26)%h%C(reset) %C(green)%ad%C(reset) %C(bold blue)%<(15,trunc)%an%C(reset)%C(ul yellow)%d%C(reset) %C(bold 0)%>|(1)%s%C(reset)' --all
#reflog
rl = reflog --date=local
#diff
dw = difftool --tool=winmerge
dc = difftool --tool=codecompare
dv = difftool --tool=vsdiffmerge
df = diff --name-status
dn = "!diffb () { git diff --name-status $@ | grep.exe -vwf .diffignore; }; diffb"
#merge
mw = mergetool --tool=winmerge
mc = mergetool --tool=codecompare
#stash
ss = stash save --include-untracked
sp = stash pop
#dry run = git merge --no-commit --no-ff
#fetc
fetchall = "!fetchall () { git fetch; git fetch nlmk_origin; }; fetchall"
ff = "!fetchall () { git fetchall; }; fetchall"
[http]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment