Skip to content

Instantly share code, notes, and snippets.

@michaelbishoff
Created September 25, 2015 00:41
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelbishoff/947ae61a62d7817ebacd to your computer and use it in GitHub Desktop.
Save michaelbishoff/947ae61a62d7817ebacd to your computer and use it in GitHub Desktop.
Useful git commands
git add <file> # Adds a file to be staged
git commit -m “Message” # Writes a message with the staged file
git push -u origin master
git diff HEAD # Views the diff of your new changes and the previous commit
git diff —staged # Diff of changes that are now staged and HEAD
git reset <file> # Opposite of git add. Upstages the file. Does Not remove them. File is still there.
git checkout — <file> # Undo. Resets file back to what it was in the last commit
git rm <file> # Removes the file from the repo
git branch # View all branches
git branch <new_branch> # Create a new branch. This does Not change which branch you’re on. NOTE: Now when you push you need to do: git push -u origin <new_branch>
git branch -d <branch> # Deletes a branch
git branch -m <new_branch_name> # Renames the current branch.
git checkout <branch> # Changes to the specified branch.
git merge <other_branch> # Merges the other branch with this one
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment