Skip to content

Git cheat sheet

Catherine DeRose edited this page Jan 29, 2018 · 6 revisions

To clone a GitHub repo and launch a local server

cd Desktop

git clone URL

cd dhlab-site/

bundle exec jekyll serve OR jekyll serve

if you get an error, try yarn install; if yarn isn't installed, type brew install yarn

To make changes and issue pull request on GitHub

git pull origin master

git status

git diff file-name

git add file-name OR git add .

git checkout -b branch-name

git commit -m 'message about the commit'

git status

git push origin branch-name

git checkout master

Additional git commands

rename a branch you're on with git branch -m new-name

undo a commit with git reset head~1 with 1 being the number of commits to undo

remove a file by deleting locally and also with git add -u file-name

find files with a keyword with git grep -l keyword - this will list all files that contain that word

delete a branch with git branch -D branch-name

see recent history with git log