---GIT COMMANDS--- CONFIG OPTIONS: git config --global user.name "Your Name" git config --global user.email your@mail.com git config --global color.ui true Basic Commands: git init # Initializes git repo git status # tells us what has changed git add [filename] # Adds a file to staging area - you can also use wildcards and also mutliple files git add -all # Adds all files at once to staging LOCAL COMMIT COMMANDS: git commit -m "Comment" # Commits changes to local repository git commit -a -m "Comment" # Commit all changes from all tracked files git commit --amend -m "Comment" # Adds something to last commit - DON'T do this after push SEE CHANGES COMMANDS: git log # Shows log git diff # Shows unstaged differences since last commit git diff --staged # Shows difference between staged versions #Don't do the following after you have pushed: git reset HEAD [filename] # Reset last commit -> HEAD refers to last commit git reset --soft HEAD^ # Reset into staging - Undos last commit, so goes one HEAD backwards git reset --hard HEAD^ # Undo last commit and all changes git reset --hard HEAD^^ # Undo last two commits and all changes git checkout -- [filename] # Blow away all cahnges since last commit REMOTE COMMANDS: git remote add [name] [address] # Adds a remote bookmark git remote -v # Shows all available remote repos git remote rm [name] # Removes remote bookmark git remote show [name] # Shows all remote branches git remote prune [name] # Cleans up remote repo, by finally deleting deleted branches git push -u [name] [branch] # Pushes local branch [branch] to remote repo [name] -u rembers the branch git push [name] [branch] # Pushes local branch to rempote repo git push [name] :[branch] # Deletes remote branch git push [name] [local-branch]:[remote-branch] # Pushes local branch to remote branch git pull # Pulls changes form the remote git clone [url] [local folder] # clones a repo git fetch # Pulls changes from repository, butdoesn't merge them git rebase # will "merge" changes to master. Without specified name will "merge" with a fetched master git rebase [branch] # will do samething with specified branch git rebase --continue # After you have edited a conflict this will continue the "merging", before that you have to stage file with git add [file] ### rebase is rebuilding you branch, by executing commit after commit, so the repo doesn't have a whole lot of merge comments BRANCH COMMANDS: git branch [name] # Creates a branch git branch -d [name] # Deletes a branch git branch -D [name] # Forces delete even with uncommited changes git branch -r # lists all remote branches git branch # lists all (local) branches git checkout [name] # Checks out a branch git checkout -b [name] # Creates an checks out branch git merge [name] # Merges the branch you are on with the one in name TAG COMMANDS: git tag # lists all tags git checkout [tag] # Checks out tag git tag -a [tag] -m "Comment" # Adds a new tag git push --tags # pushes new tags RECOVER COMMANDS: git rev-list -n 1 HEAD -- git checkout ^ -- #recovers deleted files One Command version: git checkout $(git rev-list -n 1 HEAD -- "$file")^ -- "$file" FLOW: None conflicting: You want to git push, but the server rejected the push, so you git pull and then git commit