Tutorial by Examples

There are two ways of creating aliases in Git: with the ~/.gitconfig file: [alias] ci = commit st = status co = checkout with the command line: git config --global alias.ci "commit" git config --global alias.st "status" git config --global alias....
You can list existing git aliases using --get-regexp: $ git config --get-regexp '^alias\.' Searching aliases To search aliases, add the following to your .gitconfig under [alias]: aliases = !git config --list | grep ^alias\\. | cut -c 7- | grep -Ei --color \"$1\" "#" The...
Git lets you use non-git commands and full sh shell syntax in your aliases if you prefix them with !. In your ~/.gitconfig file: [alias] temp = !git add -A && git commit -m "Temp" The fact that full shell syntax is available in these prefixed aliases also means you can us...
To temporarily mark a file as ignored (pass file as parameter to alias) - type: unwatch = update-index --assume-unchanged To start tracking file again - type: watch = update-index --no-assume-unchanged To list all files that has been temporarily ignored - type: unwatched = "!git ls-fil...
[alias] logp=log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short lg = log --graph --date-order --first-parent \ --pretty=format:'%C(auto)%h%Creset %C(auto)%d%Creset %s %C(green)(%ad) %C(bold cyan)<%an>%Creset' lgb = log --graph --date-order --branches --first-paren...
Sometimes you need to keep a linear (non-branching) history of your code commits. If you are working on a branch for a while, this can be tricky if you have to do a regular git pull since that will record a merge with upstream. [alias] up = pull --rebase This will update with your upstream so...
[ alias ] ignored = ! git ls-files --others --ignored --exclude-standard --directory \ && git ls-files --others -i --exclude-standard Shows one line per file, so you can grep (only directories): $ git ignored | grep '/$' .yardoc/ doc/ Or count: ~$ git ignored | ...
Normally, to remove files that are staged to be committed using the git reset commit, reset has a lot of functions depending on the arguments provided to it. To completely unstage all files staged, we can make use of git aliases to create a new alias that uses reset but now we do not need to remembe...

Page 1 of 1