I added a new section to my .gitconfig
file today and realized that looking
at it as a whole it's a bit overwhelming (40 commands). However, considering
it's history it just a natural evolution from my first file and simple usage
of git to now. I don't remember exactly what my first .gitconfig
looked
like, but I can guess. It pretty much only included the most basic day to day
commands:
ad = add br = branch ci = commit lg = log mr = merge co = checkout st = status
Then I realized I was doing a lot of git ad .
like commands and lots of git
xx [options]
over and over again. So I rethought my config and decided to
add a few commands:
al = add . lg = log --graph --pretty=format:'...' --abbrev-commit cim = commit -m
I think I used that for about a year, until the begging of this year when I realized I wanted single characters for all my most common commands with the extra characters being the added commands. So, I started with this:
a = add al = add --all all = add --all b = branch bd = branch -d d = diff f = fetch g = grep i = commit -m ix = commit l = log --graph --pretty=format:'...' --abbrev-commit m = merge o = checkout p = push r = rebase s = status t = tag
You'll notice that I have two add --all
commands which derives primarly from
the fact I type too fast at times and wanted them both to achive the same
result. The same goes for db
and bd
being the same command. I wanted a
bD = branch -D
command, but git is not case sensitive, so I had to remove
it. Besides, it a dangerous command, so better to have it require a few more
key strokes. I also, started a contract where they were pretty firm on the
--ff-only
merges so I added two commands to seperate my git workflow from
the companies workflow:
mn = merge --no-ff mf = merge --ff-only
Because I like to keep lots of branches around for feature development,
testing, etc. I found I was doing a lot of rebasing so I added another
section of commands for rebase. Also, because the git history for this
project is almost completely linear (--ff-only
) and I like to make lots of
check-ins on my feature branches (e.g. git i 'EOD'
) I've started doing
squash merges and those went in to this next update:
ms = merge --squash rc = rebase --continue rs = rebase --skip ra = rebase --abort
Again you might be wondering why I don't have a m = merge
command. Without
it forces me to think about what I doing when I'm merging. Next up, stashing:
st = stash sta = stash apply std = stash drop stl = stash list stp = stash pop sts = stash save
Then this morning I was hunting down a bug that was introduced a while back
and discovered the beauty of bisect
. At first I had xs = bisect start
,
but it's too easy to confuse this with xi = bisect skip
which is a stretch
to think of skip
as ignore
. The real problem those is start
re-starts
the bisect when done in the middle and that is super frustrating, so I opted
make the two most dangerous command require explicit exectuion reset
and
start
. Using x
as the starting character for all these commands is a
little awquard to type, If I find something more convient, but still logical
for bisect
this will probably change. But, for now the last section is:
x = bisect xb = bisect bad xg = bisect good xs = bisect skip xl = bisect log xv = bisect view xvs = bisect view --stat
Below is my current .gitconfig
file and I'm guess I'll continue to tweak it,
but don't see much room for any big additions.
a = add al = add --all all = add --all b = branch bd = branch -d db = branch -d c = clone d = diff ds = diff --stat f = fetch g = grep i = commit -m ix = commit l = log --graph --pretty=format:'%Cred%h %Creset- %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit -n 15 la = log --graph --pretty=format:'%Cred%h %Creset- %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit mn = merge --no-ff mf = merge --ff-only ms = merge --squash o = checkout ob = checkout -b p = push r = rebase rc = rebase --continue rs = rebase --skip ra = rebase --abort s = status st = stash sta = stash apply std = stash drop stl = stash list stp = stash pop sts = stash save t = tag x = bisect xb = bisect bad xg = bisect good xs = bisect skip xl = bisect log xv = bisect view xvs = bisect view --stat