gGit
Git stores everything in a directory, rm -rf .git to delete the git project
git --help command
Changing History
Reflog
Saves every instance of head changes
git reflog #see list of head changes
#Alternate ways to jump to reflog HEADS
git checkout -b after-commit HEAD@{1}
git reset HEAD@{1}Get specific file from past
git checkout <treeish> -- /path/to/dir/orfile.jsRebase
rewrites history, if commits not local can mess things up
could also rebase all your branch commits to occur at end of current master to avoid a merge commit
git rebase master, rebases current branch to master one
Merge master in your branch before push
git pull --rebase origin master
Squash many commits to one
git rebase -i <COMMIT_TO_IGNORE>
Squash all but topquit-save to rebase
Stash
git stash - Takes dirty changes and saves them without committing
git stash pop - Reapply last saved changes
git stash apply stash@{2}
Undoing Last Commit
git reset --hard HEAD~1 => don't keep changes
git reset --soft HEAD~1 => undo commit, but keep working changes
git revert <commit to undo> =>Commit a commit undoing last commit
Remotes
git remote -v => List origins
Add remote
git remote add origin [github url]
Selecting branch to push from and to
Reset to remote branch
git checkout -B master origin/master //-B resets if it already exists
Other
List Branches By Last Modified
Tagging
git tag -a v1.4 -m "my version 1.4"
Delete branches
git branch -d <branchname>
git remote prune origin //remove all branches not in origin
Stop tracking file
git rm --cached <file>
Remove all Untracked files and build products
git clean -fd //remove everything untracked besides what is ignored by .gitignoregit clean -fdx //remove all untracked files including those ignored by .gitignoregit clean -fdX //only remove files ignored by .gitignore
Find commit that broke it
Git grep
git grep [string] find all lines tracked by the git repo with the given string
git grep -n -C 3 TeachApp
Modifiers:
-n: show line numbers-C 5: show 5 context lines before and after-i: ignore case
Git Ignore
Git LFS(Large File Store)
Basically, lets you use large files in github by using fileptrs
Setup
brew install git-lfsTrack like
git lfs track "*.psd"or have.gitattributes
.gitattributes
Thats it, just use normal workflow
Other people
git lfs installto get huge assetsgit lfs pullto get lfs
Last updated