This is a draft cheat sheet. It is a work in progress and is not finished yet.
Switch Branches
git checkout <branch> |
switches to branch |
git checkout -b <branch> |
create a new branch that forks off of current branch |
git branch -a |
see all branches |
git stash |
store unstaged changes |
git stash pop |
restore unstaged changes |
Commit Changes
git status |
see current status of documents within git repo |
git log |
see past commits |
git diff <file> |
see changes made to specified file |
git add (-u | <files>) |
stage changed files ( -u
adds all tracked files) |
git commit -m "<message>" |
commit files |
git push origin <branch name> |
push commits to remote repo |
Undo Git Commands
git reset --hard |
revert changes back to previous commit |
git reset --hard HEAD~3 |
go back 3 commits |
git commit --amend |
change most recent commit message |
git push origin <branch name> --force |
change most recent commit message after a push |
|
|
Rebase
1 |
git checkout master |
2 |
git pull |
|
to get the most recent version of master |
3 |
git checkout <branch> |
4 |
git rebase master |
Fix any merge conflicts |
|
git add <files> |
|
git rebase --continue |
5 |
git push origin <branch> (--force, if there were merge conflicts) |
Update Git for a Project
1 |
cd to the folder that contains bDocs-Master
|
2 |
git pull (if already on correct branch) |
|
most likely will need to do a git stash
to store changes to config/app.r |
3 |
git pull |
4 |
git stash pop |
|