Last active
August 29, 2015 14:13
-
-
Save jdbevan/7123ad934da58ab09c49 to your computer and use it in GitHub Desktop.
Frequently used Git commands
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
# Update knowledge of remote branches | |
git fetch | |
# Create a new branch, starting at the existing checkout out point | |
git checkout -b {some branch name} | |
# Interactively add unstaged changes to staging | |
git add -p | |
# Un-add a file from staging | |
git reset HEAD {filename} | |
# View staged changes (to review before commit) | |
git diff --staged | |
# Show commit log | |
git log | |
# Show graphed commit log | |
git log --oneline --all --graph --decorate | |
# Interactively rebase (change) the last 7 commits | |
# !! Don't rebase pushed commits !! | |
git rebase -i HEAD~7 | |
# Unstage all changes for a commit while rebasing, useful for splitting a commit apart | |
git reset HEAD~ | |
# Change the source of the current branch to the HEAD of master | |
git rebase master | |
# Rebase local changes against un-pulled remote changes | |
git fetch | |
git rebase origin/my-awesome-branch | |
# Rename local branch | |
git branch -m old-name new-name | |
# Delete the remote branch with the old name: | |
git push origin :old-name | |
# Re-create the remote branch with the new name: | |
git push origin new-name | |
# Undo a commit, keeping files in working directory | |
git reset --soft HEAD~1 | |
# Change URL for remote | |
git remote set-url {some remote} {new git url} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment