
GitHub: Basic GIT Commands “Cheat Sheet”
Git is a free and open-source version control system that tracks changes to files over time. It’s the backbone of platforms like GitHub, but it also works independently on your computer.
This cheat sheet highlights essential Git commands for efficient version control. If I’m missing anything that should be on this, please let me know!
If you’re new to Git, consider using a desktop app to simplify the process. Here are links to download the GitHub Desktop application for Windows and Mac.
Using a desktop app can make it easier to visualize your work and interact with Git repositories.
The Basics
-
git init
- This creates a new local Git repository.
-
git add
- Adds a file to your next commit or stage.
-
git clone
- Use this to create a copy of a repository.
-
git push
- Push your changes, typically local, to the original repo.
-
git commit
- Creates a snapshot of your changes and saves it to the git directory.
Make Changes
-
git add[file]
- This will stage the file and make it ready to commit.
-
git diff
- Lists your changes and possible conflicts
-
git reset[file]
- Used to unstage the file while keeping the file changes.
-
git status
- Prints a list of new or modified files not commited.
-
git commit -m "[cool description]"
- Allows you to commit all staged files to versioned history.
Updates and Sharing
-
git remote add <'name'> <'url'>
- Connect to a remote repo
-
git pull
- Takes all the changes from the origin and merge.
-
git push
- Upload your local repo changes to the orgin remote repo
-
git fetch
- Grabs all the changes from the origin without merge.
Branch and Merge
-
git branch
- Prints a list of all your branches.
-
git log
- This will list all the commits thats in the current branch history.
-
git checkout
- Switches you to another branch and checks it out to your working directory.
-
git merge
- Merges the specified branch into the current branch.
I’ll keep expanding this cheat sheet as I discover more useful Git commands. If you have suggestions or encounter specific challenges, please don’t hesitate to share your insights!
Hope you find this helpful!
If you haven’t already, check out my Github and Bitbucket for random but helpful scripts!
Categories
Recent Posts
- PowerShell: How to Add an Alias to Every Users Mailbox and Groups in Microsoft 365
- Slack: Disable Entra ID User using a slash command.
- Slack: Retrieve Entra ID (MS365) User Information with a slash command.
- Jira Cloud: Disabling Entra ID User Accounts via Automation and Microsoft Runbook
- Jira Cloud: Restart an Azure VM using JSM Assets and Automation