git - evanmoran/quick GitHub Wiki

Information:

git status                       # State of files in your branch
git branch                       # List branches
git log                          # List commits
git show <commit>                # Show changes for a specific commit (default: HEAD)

Syncing:

git fetch                        # Get changes but don't merge them (first half of pull)
git pull <repo>                  # Pull changes from repro (default: origin)
git pull --rebase <repo>         # Pull and rebase from repro (default: origin)
git push <repo>                  # Push changes to repo (default: origin)
git merge <branch>               # Merge from a branch to current branch

Commiting:

git add <file>                   # Add <file> from working changes to staged changes
git add .                        # Add all working additions/modifications to staged changes
git reset HEAD <file>            # Un-Add <file> from stage changes 
git rm <file>                    # Remove file from git
git commit                       # Commit all staged files (will open editor message)
git commit -m "<message>"        # Commit all staged files with <message>
git checkout <file>              # Revert <file> back to its original state (warning: can loose work)

Branches:

git checkout <branch>            # Change branch
git checkout -b <branch>         # Create branch and change to it
git branch -d <branch>           # Delete local branch
git push origin --delete <branch># Delete remote branch

Other Popular Commands:

git stash                        # Push all working changes to a secret branch
git stash pop                    # Restore whatever was last stashed
git add -A                       # Add all working additions/modifications/deletions to staged
git add -p                       # Interactively choose what you add 
git checkout -p                  # Interactively choose what to revert
git clean -fxd                   # Clean all untracked files and directories

Other Information:

git remote -v                    # Show remote repositories with url info
git branch -rv                   # Show branches with most recent commit
⚠️ **GitHub.com Fallback** ⚠️