Skip to content

Instantly share code, notes, and snippets.

@stephanie-gredell
Last active November 6, 2015 02:59
Show Gist options
  • Save stephanie-gredell/17fc02b61a3d29473647 to your computer and use it in GitHub Desktop.
Save stephanie-gredell/17fc02b61a3d29473647 to your computer and use it in GitHub Desktop.
Git Commandline basic
# create a new branch
git checkout -b branch-name
# checkout an existing branch
git checkout branch name
# pull changes from branch-a into current-branch
git checkout branch-a
git pull --rebase # get all the latest changes from branch-a
git checkout current-branch
git rebase branch -a
# merge changes from branch to master
git checkout master
git merge branch-a
# quickly switch between two branches
# assume that you're doing work between master and branch
# instead of this:
git checkout master
git checkout branch
git checkout master
git checkout branch
# you can switch like this
git checkout -
# see what branch you're on
git status
# add all files (tracked and untracked)
git add .
# pull a commit into current branch
# on the branch that the commit you want to pull is on
git log # pull up the log and get the commit hash
git checkout working-branch # checkout the branch to add this commit to
git cherry-pick commithash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment