Skip to content

Instantly share code, notes, and snippets.

@johnrc
Last active September 1, 2015 21:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnrc/c244ac6e7a8f902c7783 to your computer and use it in GitHub Desktop.
Save johnrc/c244ac6e7a8f902c7783 to your computer and use it in GitHub Desktop.
Git Fundamentals

Setup Git

3 locations for settings files

  • System settings in /etc/gitconfig
  • User settings in ~/.gitconfig
  • Project settings in project/.git/config

Determine what you already have set with

git config --global --list

Recommended basic settings

git config --global user.name "First Last"
git config --global user.email "first@company.com"
git config --global core.editor vim
git config --global help.autocorrect 1
git config --global color.ui auto
# Mac / Linux
git config --global core.autocrlf input
# Windows
git config --global core.autocrlf true
git config --global format.pretty oneline

Basic Commands

Check status and such

git status
git add file.txt
git commit
git log
<modify file.txt>
git add -u
git diff hash..hash

git reset --soft HEAD~1
git reset --hard HEAD~1

git clean -n
git clean -f

git log --oneline
git log --graph
git shortlog
git shortlog -sne
git show HEAD

git remote 
git remote -v
git branch
git tag

git remote add origin https://url.com/username/project.git
git fetch origin
git log origin/master
git merge origin/master
git branch --set-upstream master origin/master
git pull # or git pull origin master

git stash
git stash list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment