Skip to content

Instantly share code, notes, and snippets.

@scott-joe
Last active June 21, 2016 17:46
Show Gist options
  • Save scott-joe/3a6eae93f6fd2a19e53c to your computer and use it in GitHub Desktop.
Save scott-joe/3a6eae93f6fd2a19e53c to your computer and use it in GitHub Desktop.
# Git commands I always forget
- Create and checkout a new branch
- `git checkout -b branchName`
- Checkout a remote branch
- `git checkout -b localBranchName origin/remoteBranchName`
- Push local branch to remote
- `git push -u origin branchName`
- Delete remote branch
- `git push origin --delete branchName`
- `git push origin :branchName`
- Prune local branches
- `git remote prune origin`
- Various resets
- `git reset --soft HEAD^`
- `git reset --hard HEAD`
- `git reset --hard origin/master`
- Push non-master branch to Heroku
- `git push heroku branchName:master`
- `git push heroku +HEAD:master`
@ne8il
Copy link

ne8il commented Jun 21, 2016

checking out a remote branch - if you want localBranchName to be the same as remoteBranchName you can just run git checkout remoteBranchName and it will create the local branch & set it to track the remote

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment