GIT STUFF

Some shortcuts

Fast BUT not Furious


Goal: Introduce shortcuts / tricks that make working with Git faster

      Execute daily task (commit, pull, push, merge, etc) fast
      Know what we are doing
      Track changes easily, also find out who to ... blame


Solutions: colors, extra info, shorthand commands, simple behavior


Assuming you are using command-line git

PLACES TO FIDDLE


~/.gitconfig

      Global git settings is here


~/.bashrc

      Additional helpers


Some other tools

      gitk, kdiff3

.BASHRC


Show current branches with color

if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
fi
if [ -f /etc/bash_completion.d/git-completion.bash ]; then
    . /etc/bash_completion.d/git-completion.bash;
fi
export GIT_PS1_SHOWDIRTYSTATE=1
 
export PS1="\[\033[01;32m\]\u@\h\[\033[01;34m\] \w\[\033[01;33m\]\$(__git_ps1 ' %s')\[\033[01;34m\] \$\[\033[00m\] "
export PS1="\[\033[G\]$PS1" 

Source: https://www.quora.com/What-are-some-useful-bash_profile-and-bashrc-tips

.BASHRC


.GITCONFIG


Colored command line, shorthand commands
[color]
  ui = true
[diff]
  tool = kidff3
[difftool]
  prompt = false
[push]
  default = simple
[alias]
  s = status
  cm = commit --message
  tree = log --graph --pretty=oneline --abbrev-commit --decorate
  adda = add --all
  resolve = mergetool
  dfa = diff -w
  dfs = diff --cached 




GIT WORK FLOW

FeaTURE BRANCHes




CREATE FEATURE BRANCH

Create new branch: git checkout -b branch_name


GIT STATUS

check file status: git status

GIT DIFF

Quickly checkout changes: git diff -w

GIT ADD

Add files that you want to commit: git add file_name

GIT COMMIT

Commit your staged changes: git commit or git commit -m "Message"


GIT MERGE

Merge a feature branch back to master: git merge branch_name


INTRODUCING REBASE

Scenario: Mark work on mark/test. Then master is updated & he need to use the new code. He can either merge, or rebase.


INTRODUCING REBASE

Rebase: git rebase branch_to_rebase_on


GIT FLOW


GIT STUFF

By Tong Huu Khiem (Mark)