• remember passwords :
    • windows:
      • git config --global credential.helper wincred
    • linux:
      • git config --global credential.helper cache
      • git config --global credential.helper cache –timeout=`
  • Posh-Git : helps powershell with git
  • git config --global "<user name>"
  • git config --global <e-mail>
  • git config --global core.editor vim

Status : git status Fetch : git fetch


  • git config
    • --list : view list of all stuff

Set up remote:

  • make branch track remote:
    • Given a branch foo and a remote upstream:
      • As of Git 1.8.0 : git branch -u upstream/foo
    • Or, if local branch foo is not the current branch:
      • git branch -u upstream/foo foo

Help : git help <verb>

Setting up a repository

  • git init : make a new repository
  • git clone <URL> <directory name - optional> : pull down a repository, optionally put it into a directory with name <directory name>


  • git add <filename> : will add a file to the next comment “staging”
  • git status : will report repository status
  • git diff : shows you what you have changed in your files
  • git commit:
    • -m <message> : puts message in directly
    • -a : automatically stages any changed files
    • --amend : modifies the prior commit, you can add files and notes
  • git rm : removes a file, requires a commit to complete
    • --chached : removes from staging area but keeps in directory
  • git pull : pulls down remote repository into local
    • --rebase : makes a mirror rather than a branch, does not cause merging when you push
  • git mv : rename or move file
  • git log : history of commits
    • -p : shows the changes between commits
    • -<n> : shows only the most recent commits
    • --since : since a date
    • --stat : shows stats for each commit (num of files changed etc..)
    • --pretty : takes a number of args to prettify output
      • --pretty=oneline : makes every commit one line
      • --pretty=short : makes a shortened format
      • --pretty=full :
      • --pretty=fuller :
      • --pretty=format: <format> : formats output per format spec ( <- could make an output to a text file to run a script and generate a nice log
  • git push [remote-name] [branch-name] : pushes up


  • git tag : shows tags
    • -a <version> : saves a version tag
    • -m <message> : saves a message
    • after the fact : git tag -a <version> <beginning of commit checksum>
  • git show <verion> : shows tagged data
  • git push <remoterepo> --tags : pushes tag locations
  • git checkout -b <newBranch> <tag> : checkout a tagged commit


  • git branch : shows available branches
    • <newBranch> : makes a new branch at your current location
    • -d <branch> : deletes a branch
    • -v : shows shows last commit on each branch
    • --merged : shows which branches have been merged into the working branch
    • --no-merged : branches which you have not merged in
  • git checkout <branch> : switches to a new branch, if branch does not exist, it is created
  • git merge <branch in> : merges branch in with the branch which you are currently on
  • Deleting:
    • local : git branch -d <branch>
    • remote : git push origin :<remoteBranch>

Ignoring files:

  • Make a file called .gitignore
    • lines with # are ignored
    • use glob notation
    • can use “/” for paths
    • EX:
      • *.[oa] : ignore files ending in “o” or “a”
      • *~ : ignore files ending in ~
    • thoughts : binaries (o,a). temps (tmp, *~), logs

get a remote branch:

  • git fetch <origin> <branch>
  • git checkout <branch>

Remove all of some file type

  • git filter-branch -f --index-filter 'git rm --ignore-unmatch *.pptx

Set Atom as Git editor

  • git config --global core.editor "atom --wait"

go back to a prior commit (you will loose any changes)

  • git reset --hard <commit to go to ex:b5c3d8b>

Certificate problems

echo -n | openssl s_client -showcerts -connect <domain, ex:> 2>/dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/Documents/gitcerts.pem

git config --global http.sslCAInfo ~/Documents/gitcerts.pem