Show Menu
Cheatography

SAS Workshops Git CLI Cheatsheet Cheat Sheet (DRAFT) by

For NI Module on Git Tools

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Watch Command

#!/bin/bash
ARGS="${@}"
clear; 
while(true); do 
  OUTPUT=
$ARGS
  clear   echo -e "${OUTPUT[@]}"   sleep 2 done
This mimics the native linux watch command which is not present in Git Bash.

Add this content to a file named watch (no extension) in C:\Program Files­\Git­\us­r\bin\

After that you can watch any cmd by typing
watch CMD_TO­_WATCH

Useful Aliases

Command
Alias Definition
Result
git new
git config --global alias.new '!git init && git symbolic-ref HEAD refs/heads/main'
creates new repo with main as default branch name instead of master
git graph
git config --global alias.graph 'log --graph --abbrev-commit --pretty=oneline --decorate --color=always'
creates a nice commit graph
git watch-status
git config --global alias.watch-status '! watch git -c color.status=always status'
watches git status with colors
git stashall
git config --global alias.stashall 'stash save --include-untracked'
stashes untracked files as well as tracked files
git cloneall
git config --global alias.cloneall 'clone --recurse-submodules --no-hardlinks'
Recurses submodules (and adds no hard-l­inks)
 

Keeping a Fork Up To Date

#add remote if not already added
git remote add upstream URL_TO_UPSTREAM
#fetch remote branches
git fetch upstream
#For each branch:
   #merge changes
   git merge upstream/MYBRANCH
   #or rebase
   git rebase upstream/MYBRANCH
   #push changes to fork (origin)
   git push origin MYBRANCH
Use these commands to keep a fork up to date with an upstream reposi­tory.

Setting up LVCompare and LVMerge

#Setup LVCompare
git config --global diff.tool LVCompare
git config --global difftool.LVCompare.cmd 'C:\\viscc\\vidiff.exe "$LOCAL" "$REMOTE" -nobdcosm -nobdpos'
$Setup LVMerge
git config --global merge.tool LVMerge
git config --global mergetool.LVMerge.cmd 'C:\\viscc\\vimerge.exe "$BASE" "$REMOTE" "$LOCAL" "$MERGED" -nobdcosm -nobdpos'
#Call LVCompare
git difftool
#Call LVMerge
git mergetool
First clone the repo at https:­//g­ith­ub.c­om­/sm­ith­ed/­vic­ompare.

Build all 4 build specs in order and then run the installer.

Push to new gitlab from CLI