Created by Devan Huapaya / @devanIpsum
A collection of code
Different version of the same repository
Url where collection is hosted
Copy of repository to another repository owned by the forker ™
Local copy of a repository
Someone contributing to a project
Provides a common place for projects that have more than one collaborator
git init # Creates git folder and starts a git history
git add -A # Stages everything in the directory and child directories
git commit -m “first commit” # Commits those changes
git remote add origin https://github.com/imdevan/intro-to-git.git # Tells .git where to store files remotely
git push -u origin master # Push and intiate the master branch remotely
git clone [repo url] # Copy a repository from a remote url
git add -A # Stages everything in the directory and child directories
git commit -m “commit message” # Commits those changes
git push # Push changes to remote repo
git pull # Pull down any changes that were made to a remote branch
git branch [branch name] # Creates a new branch (shows branches if no name is provided)
git checkout [branch name] # Switch to branch name provided
git checkout -b [new branch name] # Creates a new branch and switces to it
git checkout [feature branch] # Switch to branch
git merge master # Merge master into branch
or
git merge master [feature branch] # Merge feature branch into master
git checkout [feature branch] # Switch to branch
git rebase [remote]/[branch] # Put your changes on top of remote branch
git rebase [remote]/[branch] -i # Use this to squash multilple commits into one
Makes local branch of pull request for testing
git fetch upstream pull/[pull request number]/head:[branch name] # Get pull request
git checkout [branch name] # Switch to branch
(ie git fetch upstream pull/1/head:test)
git stash # hide last changes
git stash pop # brings back changes
git stash clear # clear all stashed changes
git stash list # show all stashed changes
git checkout -- [file path] # Reverts file to last commit (changes lost)
git fetch upstream # Bring upstream into local environment
git reset --hard upstream/master # Set local environment to upstream
git revert [commit] # Go back to commit number
git reset --hard [commit] # Reset back to commit number
git fetch upstream # Bring upstream into local environment
git reset --hard upstream/master # Set local environment to upstream
git push origin master --force # push changes back up to your fork
Created by Devan Huapaya / @devanIpsum
workflow images from https://www.atlassian.com/git/tutorials/merging-vs-rebasing octocats from https://octodex.github.com/