Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sample of git config file (Example .gitconfig)
[user]
name = Pavan Kumar Sunkara
email = pavan.sss1991@gmail.com
username = pksunkara
[core]
editor = vim
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
excludesfile = ~/.gitignore
[sendemail]
smtpencryption = tls
smtpserver = smtp.gmail.com
smtpuser = pavan.sss1991@gmail.com
smtppass = password
smtpserverport = 587
[web]
browser = google-chrome
[instaweb]
httpd = apache2 -f
[rerere]
enabled = 1
autoupdate = 1
[push]
default = matching
[color]
ui = auto
[color "branch"]
current = yellow bold
local = green bold
remote = cyan bold
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
new = green bold
whitespace = red reverse
[color "status"]
added = green bold
changed = yellow bold
untracked = red bold
[diff]
tool = vimdiff
[difftool]
prompt = false
[github]
user = pksunkara
token = token
[gitflow "prefix"]
feature = feature-
release = release-
hotfix = hotfix-
support = support-
versiontag = v
[sequence]
editor = interactive-rebase-tool
[alias]
a = add --all
ai = add -i
#############
ap = apply
as = apply --stat
ac = apply --check
#############
ama = am --abort
amr = am --resolved
ams = am --skip
#############
b = branch
ba = branch -a
bd = branch -d
bdd = branch -D
br = branch -r
bc = rev-parse --abbrev-ref HEAD
bu = !git rev-parse --abbrev-ref --symbolic-full-name "@{u}"
#############
c = commit
ca = commit -a
cm = commit -m
cam = commit -am
cem = commit --allow-empty -m
cd = commit --amend
cad = commit -a --amend
ced = commit --allow-empty --amend
#############
cl = clone
cld = clone --depth 1
clg = !sh -c 'git clone git://github.com/$1 $(basename $1)' -
clgp = !sh -c 'git clone git@github.com:$(git config --get user.username)/$1 $1' -
#############
cp = cherry-pick
cpa = cherry-pick --abort
cpc = cherry-pick --continue
#############
d = diff
dp = diff --patience
dc = diff --cached
dk = diff --check
dck = diff --cached --check
dt = difftool
dct = difftool --cached
#############
f = fetch
fo = fetch origin
fu = fetch upstream
#############
fp = format-patch
#############
fk = fsck
#############
g = grep -p
#############
l = log --oneline
lg = log --oneline --graph --decorate
#############
ls = ls-files
lsf = !git ls-files | grep -i
#############
m = merge
ma = merge --abort
mc = merge --continue
ms = merge --skip
#############
o = checkout
om = checkout master
ob = checkout -b
#############
pr = prune -v
#############
ps = push
psf = push -f
psu = push -u
pst = push --tags
#############
pso = push origin
psao = push --all origin
psfo = push -f origin
psuo = push -u origin
#############
psom = push origin master
psaom = push --all origin master
psfom = push -f origin master
psuom = push -u origin master
psoc = !git push origin $(git bc)
psaoc = !git push --all origin $(git bc)
psfoc = !git push -f origin $(git bc)
psuoc = !git push -u origin $(git bc)
psdc = !git push origin :$(git bc)
#############
pl = pull
pb = pull --rebase
#############
plo = pull origin
pbo = pull --rebase origin
plom = pull origin master
ploc = !git pull origin $(git bc)
pbom = pull --rebase origin master
pboc = !git pull --rebase origin $(git bc)
#############
plu = pull upstream
plum = pull upstream master
pluc = !git pull upstream $(git bc)
pbum = pull --rebase upstream master
pbuc = !git pull --rebase upstream $(git bc)
#############
rb = rebase
rba = rebase --abort
rbc = rebase --continue
rbi = rebase --interactive
rbs = rebase --skip
#############
re = reset
rh = reset HEAD
reh = reset --hard
rem = reset --mixed
res = reset --soft
rehh = reset --hard HEAD
remh = reset --mixed HEAD
resh = reset --soft HEAD
#############
r = remote
ra = remote add
rr = remote rm
rv = remote -v
rn = remote rename
rp = remote prune
rs = remote show
rao = remote add origin
rau = remote add upstream
rro = remote remove origin
rru = remote remove upstream
rso = remote show origin
rsu = remote show upstream
rpo = remote prune origin
rpu = remote prune upstream
#############
rmf = rm -f
rmrf = rm -r -f
#############
s = status
sb = status -s -b
#############
sa = stash apply
sc = stash clear
sd = stash drop
sl = stash list
sp = stash pop
ss = stash save
ssk = stash save -k
sw = stash show
st = !git stash list | wc -l 2>/dev/null | grep -oEi '[0-9][0-9]*'
#############
t = tag
td = tag -d
#############
w = show
wp = show -p
wr = show -p --no-color
#############
svnr = svn rebase
svnd = svn dcommit
svnl = svn log --oneline --show-commit
#############
subadd = !sh -c 'git submodule add git://github.com/$1 $2/$(basename $1)' -
subup = submodule update --init --recursive
subpull = !git submodule foreach git pull --tags origin master
#############
assume = update-index --assume-unchanged
unassume = update-index --no-assume-unchanged
assumed = !git ls -v | grep ^h | cut -c 3-
unassumeall = !git assumed | xargs git unassume
assumeall = !git status -s | awk {'print $2'} | xargs git assume
#############
bump = !sh -c 'git commit -am \"Version bump v$1\" && git psuoc && git release $1' -
release = !sh -c 'git tag v$1 && git pst' -
unrelease = !sh -c 'git tag -d v$1 && git pso :v$1' -
merged = !sh -c 'git o master && git plom && git bd $1 && git rpo' -
aliases = !git config -l | grep alias | cut -c 7-
snap = !git stash save 'snapshot: $(date)' && git stash apply 'stash@{0}'
bare = !sh -c 'git symbolic-ref HEAD refs/heads/$1 && git rm --cached -r . && git clean -xfd' -
whois = !sh -c 'git log -i -1 --author=\"$1\" --pretty=\"format:%an <%ae>\"' -
serve = daemon --reuseaddr --verbose --base-path=. --export-all ./.git
#############
behind = !git rev-list --left-only --count $(git bu)...HEAD
ahead = !git rev-list --right-only --count $(git bu)...HEAD
#############
ours = "!f() { git checkout --ours $@ && git add $@; }; f"
theirs = "!f() { git checkout --theirs $@ && git add $@; }; f"
subrepo = !sh -c 'git filter-branch --prune-empty --subdirectory-filter $1 master' -
human = name-rev --name-only --refs=refs/heads/*
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Temporary files #
###################
*.swp
*.swo
*~
# Packages #
############
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
# Logs and databases #
######################
*.log
*.sql
*.sqlite
# OS generated files #
######################
.DS_Store*
ehthumbs.db
Icon?
Thumbs.db
*.lock
@xparta

This comment has been minimized.

Copy link

commented Jul 22, 2015

[http]
[https]
proxy = https://172.20.255.254:8080
[user]
email = tomarobaski@gmail.com
name = xparta
[http]
proxy = http:labtest:user123
proxy = http://labtest:user123@http

@FEiSPARSSync

This comment has been minimized.

Copy link

commented Oct 25, 2016

Thank you, this is very helpful!

@dinm

This comment has been minimized.

Copy link

commented Nov 29, 2016

Thanks!

@vikashb72

This comment has been minimized.

Copy link

commented Jan 6, 2017

How do i add this command to my .gitconfig ?

git config tar.tar.xz.command "xz -c"

@linux-modder

This comment has been minimized.

Copy link

commented Jan 23, 2017

@vikashb72, globally or in a particular repo?

@karnikamit

This comment has been minimized.

Copy link

commented May 2, 2017

Thanks.

@tkiran

This comment has been minimized.

Copy link

commented Jun 8, 2017

Thanks !

@kuiwang

This comment has been minimized.

Copy link

commented Jun 14, 2017

Cool!
Thanks

@b0r1sp

This comment has been minimized.

Copy link

commented Jul 7, 2017

suggestion for an additional alias:
hist = log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short

@is2ei

This comment has been minimized.

Copy link

commented Jul 25, 2017

Thanks. It helps a lot!

@Yousha

This comment has been minimized.

Copy link

commented Aug 13, 2017

For GITIGNORE you can simply use https://github.com/github/gitignore

@uniqueg

This comment has been minimized.

Copy link

commented Sep 8, 2017

Thanks!

Another alternative for .gitignore files: https://www.gitignore.io/

@pseudeis

This comment has been minimized.

Copy link

commented Dec 7, 2017

Thanks !

@markediez

This comment has been minimized.

Copy link

commented Dec 29, 2017

Thanks! Also, if you know, what kind of format is this? I've seen it around (e.g. .aws/config file for aws cli) but I haven't come across the name for it.

@kisoku

This comment has been minimized.

@mcpherson

This comment has been minimized.

Copy link

commented Jan 17, 2018

Thanks for posting. I'm curious, what's the difference between the following?

[user]
        username = ...

and

[github]
        user = ...

I'm exploring the use of multiple GitHub accounts (without SSH) and these seem like they might be useful/related. My early GitHub and StackOverflow searches were not very helpful.

@cparada10

This comment has been minimized.

Copy link

commented Feb 27, 2018

Does anyone know if you can use variables in a gitconfig include path?

@hendisantika

This comment has been minimized.

Copy link

commented Mar 10, 2018

I already add this command, but still I can't clone repo from outside my proxy :
git config --global http.proxy http://hendi santika:myp@ssw0rd@proxy.server.co.id:8080

Any suggest?
Thanks

@lebeerman

This comment has been minimized.

Copy link

commented Jun 6, 2018

thanks!

@Zooloo2014

This comment has been minimized.

Copy link

commented Jul 4, 2018

Very useful! Thanks.
You don't have a [credential] section. Do you know how that would be used?

@paulobastos-ezvida

This comment has been minimized.

Copy link

commented Sep 3, 2018

@hendisantika you need change your password encoding special characters:
git config --global http.proxy http://hendi santika:myp%40ssw0rd@proxy.server.co.id:8080

https://www.w3schools.com/tags/ref_urlencode.asp

@emb03

This comment has been minimized.

Copy link

commented Sep 27, 2018

Is there a way to specify two different .gitignore files in the gitconfig file?
Something like this:
[remote "origin"]
.gitignore = .gitignore-origin
[remote "ac"]
.gitignore = .gitignore-ac

@jmarsac

This comment has been minimized.

Copy link

commented Sep 28, 2018

@Zooloo2014

[credential "https://github.com"]
        username = scott18

to define username for github.com only

@diazgilberto

This comment has been minimized.

Copy link

commented Jan 21, 2019

I'm trying to find the full list of options I can use inside the .gitconfig file. Where I can find those?

@awesometic

This comment has been minimized.

Copy link

commented Mar 16, 2019

Thanks, this is great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.