Catalog / GitHub Cheat Sheet
GitHub Cheat Sheet
A comprehensive cheat sheet covering essential GitHub commands, workflows, and features for version control and collaboration.
Basic Git Commands
Configuration
|
Sets your name for commit messages. |
|
Sets your email address for commit messages. |
|
Sets VS Code as the default editor for commit messages (replace |
|
Lists all git configuration settings. |
Starting a Repository
|
Initializes a new Git repository in the current directory. |
|
Clones a repository from a remote URL. |
Basic Workflow
|
Shows the status of the working directory and staging area. |
|
Adds a file to the staging area. |
|
Adds all changes in the current directory to the staging area. |
|
Commits the staged changes with a descriptive message. |
Branching and Merging
Branch Management
|
Lists all local branches. The current branch is marked with an asterisk (*). |
|
Creates a new branch. |
|
Switches to the specified branch. |
|
Creates and switches to a new branch. |
|
Deletes a branch (only if it has been merged). |
|
Forces deletion of a branch (even if it hasn’t been merged). |
Merging Branches
|
Merges the specified branch into the current branch. |
|
Opens a merge tool to resolve conflicts. |
|
Visualize the branch and merge history. |
Rebasing
|
Rebases the current branch onto the specified branch. Rewrites commit history. |
|
Abort the rebase process. |
|
Continue the rebase process after resolving conflicts. |
Remote Repositories
Connecting to Remotes
|
Adds a remote repository named ‘origin’. |
|
Lists all remote connections. |
|
Shows information about the remote ‘origin’. |
Pushing and Pulling
|
Pushes the specified branch to the remote ‘origin’. |
|
Sets up tracking information for the branch so that |
|
Pulls changes from the remote ‘origin’ to the specified branch. |
|
Fetches all changes from the remote but does not merge them. |
GitHub Specifics
|
Generates a request pull message. |
|
Clone a repository. Requires GitHub CLI ( |
Undoing Changes
Undoing Local Changes
|
Discards changes in the working directory for a specific file. |
|
Alternative to |
|
Removes a file from the staging area. |
|
Dry run to see which files would be removed by |
|
Removes untracked files from the working directory. |
Undoing Commits
|
Amends the last commit with new changes or message. |
|
Resets the last commit, keeping the changes in the staging area. |
|
Resets the last commit, keeping the changes in the working directory. |
|
Resets the last commit and discards the changes. Use with CAUTION. |
|
Creates a new commit that reverts the changes from the specified commit. Safe way to undo changes in shared repositories. |