Created
January 16, 2014 14:07
-
-
Save cyntss/8455539 to your computer and use it in GitHub Desktop.
Github command lines
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# List remote branches | |
git branch -r | |
# Checkout and track a remote branch | |
git checkout -t origin/<remote-name> | |
# Track a remote branch | |
git branch -t <local-name> origin/<remote-name> | |
# Format n commits into n patches | |
git format-patch -<n> <sha1-of-commit> | |
# Remove a single commit (that's not yet pushed!) from history | |
git rebase --onto <sha1-of-bad-commit>^ <sha1-of-bad-commit> | |
# Throw away all local commits | |
git reset [--hard|--soft] origin/<branch> | |
# Reset in the middle of a merge | |
git merge --abort | |
git reset --merge # For older versions of git | |
# Show contents of a stash as diff | |
git stash show -u | |
# Merge commits interactively | |
git rebase -i | |
# Create a new branch and pull other user's changes (e.g. merge a pull request) | |
git checkout -b <new_local_branch_name> | |
git pull --rebase https://<my_user>@github.com/<other_user>/<project> <branch> | |
# Reset a fork | |
git remote add upstream git://github.com/project/project.git | |
git fetch upstream | |
git branch backup | |
git reset --hard upstream/master | |
git push --force | |
# Create a new tag | |
git tag -a 0.1.2 -m 'Version 0.1.2' | |
# Checkout a tag into a new branch | |
git checkout tags/<tag name> -b <branch name> | |
# Compare two files in different branches | |
git diff branch1:path/to/file branch2:path/to/file | |
# Checkout a single file from different branch | |
git checkout <branch> -- path/to/file | |
# Remove untracked files and dirs from working copy | |
git clean -f -d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment