git Cheat Sheet
git status
git add .
git add this\that.file
git commit -m "this helpful"
git push
git push origin --force
git log
erases previous history
git reset --hard g0BblyG00kHash
retain history
git checkout -b new_branch 23423432
git add -A
git commit
git checkout master
git merge new_branch
another option
cd /tmp
git clone https://github.com/toby-marks/tobybase.git
cd tobybase
git checkout 85add47b28670abaf99b17e010edeafb2fbb3189
cp content/posts/*.md /path/to/tobybase/working/directory/content/posts/
cd /path/to/tobybase/working/directory
git add -A
git commit -m "Restoring files lost after 85add47b28670abaf99b17e010edeafb2fbb3189"
Usage Summary
Here is a quick reference to help you with the basics:
COMMAND | DESCRIPTION |
---|---|
git clone | Downloads the repo to your local device |
git add | Adds files to the tracking list |
git commit | Adds all tracked files to the commit queue |
git push | Uploads all of the commit queue to your remote repo |
git push –force | Uploads all of the commit queue to your remote repo, overwriting without a merge |
git pull | Downloads any changed files to your local repo |
git reset –hard | Downloads any changed files to your local repo, ignoring your changes and simply overwriting your files |
git status | Shows what git knows about, what has changed |
git log | Shows all commits and their comments |