Skip to content

Instantly share code, notes, and snippets.

@gregglind
Created July 27, 2016 14:56
Show Gist options
  • Save gregglind/a55079a1b9c7f55525c4acf0edc56960 to your computer and use it in GitHub Desktop.
Save gregglind/a55079a1b9c7f55525c4acf0edc56960 to your computer and use it in GitHub Desktop.
Git'ing Better All The Time

Making Git Awesome In Your CLI

Ye Olde School - Improve it with Bash

  1. Git info in your prompt

    brew install vcprompt

    vcprompt original link

    My own flavor:

    # in ~/.profile
    
    vcprompt_timeout ()
    {
            A=$(vcprompt -t 100 -f "[%n:%b%u%m]") && echo $A || vcprompt -f "[%n:%b_]"
    }
    	
    # get vcprompt into prompt
    vcprompt &>/dev/null  && \
    export PS1='\! \u \w $(vcprompt_timeout)\$
  2. Tab-completions, because we are lazy

    via bob the cow's Install Bash git completion

    brew install bash-completion
    	
    # in ~/.profile
    if [ -f $(brew --prefix)/etc/bash_completion ]; then
    	. $(brew --prefix)/etc/bash_completion
    fi
    
  3. Issues, let's solve that.

    brew install ghi

    ghi create -m "some new issue"
    
  4. Better git client

    brew install hub

    # ~/.profile:  
    hub pull-request -i 272  # pr and convert issue to pull!
    
  5. Useful (?) aliases in ~/.gitconfig

    [alias]
    ci = commit
    br = branch
    co = checkout
    st = status
    di = diff
    re = rebase
    re1 = rebase -i HEAD~2
    rei = rebase -i HEAD~10
    lst = ls-tree
    lsf = ls-files
    cat = cat-file
    dic = diff --cached
    din = diff --name-only
    dins = diff --name-status
    S = stash
    SA = stash apply
    log1 = log --remotes --branches --oneline --decorate #--source
    glog = log --graph
    fixup = !git commit --fixup HEAD && git rebase --interactive --autosquash HEAD~2
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment