Almost every developer who once started to use Git as a version control system knows how efficient you can be in the console with this tool. With very short commands one is able to check-in and check-out code faster than you think.
All needed steps to interact with your code repository can be executed on the command line. There is no need to use any klikibunti1 (a graphical user interface). But with the right .gitconfig file in our home directory (~), you can become faster, much faster! But first things first.
.gitconfig File
The .gitconfig file allows the user to make some personal settings which affect git and the way how you can work with the version control system (VCS). Since, I am using git for several years in different project I started to define my own aliases for the standard git commands. Aliases allow you to find a more handy substitution for the standard git commands. So instead of writing git commit -a -m "some nice commit message" you could define e.g. git cam "some nice commit message.
Better Logs
These aliases allow me to find things faster in the log. The commands shows the revision graph. Quite equivalent to that what the GUIs gives you.
lg1 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)'lg1a = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --alllgs = log --graph --stat --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)'
lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)'lg2a = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --alllg = !"git lg1"ls = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cgreen\\ [%cn]" --decoratell = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cgreen\\ [%cn]" --decorate --numstatFaster Integration
The must to have commands. All standard just add in your [alias] and test these commands:
a = addcm = commit -mcam = commit -a -mcia = commit --amendd = diffds = diff --statdsh = diff --stat master..HEADdc = diff --cacheddt = difftoolmt = mergetools = status -sco = checkoutcob = checkout -bchp = cherry-picph = pushpl = pullt = tagpht = push --tagPocket Knife
My personal (Swiss) pocket knife. If you do not know where you find a file, e.g. class, package, config, whatever, you can use these commands to find it.
# Find a file path in codebase:fg = "!git ls-files | grep -i"Usage
adam@adam-laptop:~/Development/vim-settings$ git fg visu.vim/bundle/visual-splitIf you are more interested in the content you can use another command. This will grep all files and there lines where your search terms can be located:
# Search/grep your entire codebase for a string: gr = grep -IiLet’s search for the string “abort”
adam@adam-laptop:~/Development/vim-settings$ git gr abort.vim/autoload/pathogen.vim:function! pathogen#infect(...) abort.vim/autoload/pathogen.vim:function! pathogen#split(path) abort.vim/autoload/pathogen.vim:function! pathogen#join(...) abort.vim/autoload/pathogen.vim:function! pathogen#legacyjoin(...) abort.vim/autoload/pathogen.vim:function! pathogen#cycle_filetype() abort.vim/autoload/pathogen.vim:function! pathogen#is_disabled(path) abort.vim/autoload/pathogen.vim:function! pathogen#surround(path) abort.vim/autoload/pathogen.vim:function! pathogen#interpose(name) abort.vim/autoload/pathogen.vim:function! pathogen#helptags() abort.vim/autoload/pathogen.vim:function! pathogen#execute(...) abort.vim/autoload/pathogen.vim:function! pathogen#is_absolute(path) abort.vim/autoload/pathogen.vim:function! pathogen#expand(pattern, ...) abort.vim/autoload/pathogen.vim:function! pathogen#slash() abort.vim/autoload/pathogen.vim:function! pathogen#separator() abort.vim/autoload/pathogen.vim:function! pathogen#glob(pattern) abort.vim/autoload/pathogen.vim:function! pathogen#glob_directories(pattern) abort.vim/autoload/pathogen.vim:function! pathogen#uniq(list) abort.vim/autoload/pathogen.vim:function! pathogen#fnameescape(string) abort.vim/autoload/pathogen.vim:function! pathogen#runtime_findfile(file,count) abortYour Reminder
Have you forgotten an alias? No problem! Just list your settings with:
# List all aliasesla = "!git config -l | grep alias | cut -c 7-"Footnotes
-
Klickibunti. Wikipedia. Published February 2018. Accessed February 2018. ↩