Skip to content

Instantly share code, notes, and snippets.

@peacengell
Forked from thieryl/001_ansible _deep_dive.md
Created July 20, 2018 05:57
Show Gist options
  • Save peacengell/aa9ec19d0dbedf30a6785dddaf0b2c77 to your computer and use it in GitHub Desktop.
Save peacengell/aa9ec19d0dbedf30a6785dddaf0b2c77 to your computer and use it in GitHub Desktop.
[Yesterday I learned...] Continous learning #general

Git Tips and tricks


01 - list you git configuration

thieryl@thieryl[09:52:44]: $ git config --list 
user.email=thiery.louison@redboxdigital.com
user.name=thiery louison
alias.aa=add --all
alias.bv=branch -vv
alias.ba=branch -ra
alias.bd=branch -d
alias.ca=commit --amend
alias.cb=checkout -b
alias.cm=commit -a --amend -C HEAD
alias.cam=commit -am
alias.ci=commit -a -v
alias.co=checkout
alias.di=diff
alias.ll=log --pretty=format:%C(yellow)%h%Cred%d\ %Creset%s%Cblue\ [%cn] --decorate --numstat
alias.ld=log --pretty=format:%C(yellow)%h\ %C(green)%ad%Cred%d\ %Creset%s%Cblue\ [%cn] --decorate --date=short --graph
alias.ls=log --pretty=format:%C(green)%h\ %C(yellow)[%ad]%Cred%d\ %Creset%s%Cblue\ [%cn] --decorate --date=relative
alias.mm=merge --no-ff
alias.st=status --short --branch
alias.tg=tag -a
alias.pu=push --tags
alias.un=reset --hard HEAD
alias.uh=reset --hard HEAD^
color.ui=auto

02 - List of the remote branches

To see all the branches, try the following command:

thieryl@thieryl[09:50:31]: $ git branch -a 
  master
* my_newfeature
  remotes/origin/master
  remotes/tlo/master
[~/.dotfiles]

03 - Add a local branch tracking the remote branch.

$ git branch --track style origin/style
Branch style set up to track remote branch style from origin.
$ git branch -a
  style
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/style
  remotes/origin/master
$ git hist --max-count=2
* 2faa4ea 2011-03-09 | Changed README in original repo (HEAD, origin/master, origin/HEAD, master) [Thiery Louison]
* 6e6c76a 2011-03-09 | Updated index.html (origin/style, style) [Thiery Louison]

04 - Map a local branch tracking to a remote branch

thieryl@thieryl[09:47:38]: $ git checkout -b my_newfeature -t tlo/master
thieryl@thieryl[09:50:23]: $ git status -v 
On branch my_newfeature
Your branch is up to date with 'tlo/master'.

nothing to commit, working tree clean
[~/.dotfiles]
thieryl@thieryl[09:50:31]: $ 

thieryl@thieryl[09:48:43]: $ git ld
* e5480c7 2018-07-19 (HEAD -> my_newfeature, tlo/master, origin/master, master) Add new git alias [thiery louison]
* 508b1b4 2018-07-19 Add .gitconfig file to repo [thiery louison]
* 33ac493 2018-07-04 Add new functions [thiery louison]
* c0026b1 2018-07-02 Add new aliases and new variables [thiery louison]
*   210c4ed 2018-06-08 Merge branch 'master' of github.com:thieryl/dotfiles [thiery louison]
|\  
| * 9598e8c 2018-05-23 Delete .bashrc_old [GitHub]
| * ab974f7 2018-05-23 Update .bashrc_old [GitHub]
* | d832d62 2018-06-08 Add new aliases [thiery louison]
|/  
* 8a2acd3 2018-05-23 Add .bash_promt [thiery louison]
* c4fc360 2018-05-23 Add new alias [thiery louison]
* 2d1d74c 2017-09-25 Modified some functionality [thiery louison]
* 9ba5d65 2017-09-12 Add the password generator pgen to the .bash_aliases file [thiery louison]
* 1cf2a81 2017-08-31 Add new alias for git [thiery louison]
* 8033abc 2017-08-31 Add new alias and new functions [thiery louison]
* 43ba75d 2017-08-31 Initial commit [thiery louison]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment