Enterprise SONiC Bootcamp Register Now

Sign Up

Git Version Control Cheat Sheet

This cheat sheet serves as a quick reference for developers and IT professionals, enabling efficient and effective Git version control management.

Git Version Control Commands

This cheat sheet provides a comprehensive collection of essential Git commands for managing and collaborating on code repositories. It covers a wide range of tools and techniques used for initializing repositories, managing branches, committing changes, handling remote repositories, and performing advanced tasks like rebasing and stashing. Whether you’re tracking changes, merging branches, resolving conflicts, or maintaining a clean commit history, these commands will help streamline your version control process and enhance your software development workflow.

Git Version Control

Setup and Config

Creating Repositories

Set user name
Set user email
List all config settings

Initialize a new Git repository
Clone an existing repository

Basic Snapshotting

Branching and Merging

Add files to the staging area
Add all files to the staging area
Commit changes
Commit all changes (skipping the staging area)
View commit history
View commit history with one line per commit

List all branches
Create a new branch
Switch to a branch
Create and switch to a new branch
Merge a branch into the current branch
Delete a branch

Remote Repositories

Viewing and Comparing

Show changes in the working directory

Show changes between commits
Show changes between working directory and last commit
Show changes in the staging area

List all branches
Create a new branch
Switch to a branch
Create and switch to a new branch
Merge a branch into the current branch
Delete a branch

Rewriting History

Resetting and Reverting

Amend the last commit
Rebase the current branch onto another branch
Abort a rebase
Continue a rebase after resolving conflicts
Interactively rebase

Unstage a file
Reset the staging area but keep the working directory
Reset the staging area and the working directory
Revert a commit

Tagging

Ignoring Files

List all tags
Create a new tag

Create an annotated tag

Push a tag to a remote repository
Delete a local tag

Delete a remote tag

Add a file or pattern to .gitignore
Show ignored files

Cleaning Up

Submodules

List all tags
Create a new tag
Create an annotated tag

Push a tag to a remote repository
Delete a local tag

Delete a remote tag

Add a submodule
Initialize submodules
Update submodules
Clone a repository and initialize submodules

Alias


Create an alias
Example: Create a short alias for ‘git status’

What is Git?

Git is a powerful distributed version control system designed to help developers track changes in their code, collaborate with others, and manage projects efficiently. Created by Linus Torvalds in 2005, Git has become the standard for version control in the software development industry. It provides robust tools for managing project history, branching and merging code, and working
with remote repositories.

Git Tips

    • Descriptive Commits: git commit -m “Fix login issue”
    • Branch for Features: git checkout -b feature/new-feature
    • Stash Changes: git stash
    • Rebase for Clean History: git rebase main.
    • Use Aliases: git config –global alias.co checkout
    • .gitignore: echo “node_modules/” >> .gitignore
    • Check Status: git status
    • View Logs: git log –oneline –graph –all
    • Review Changes: git diff
    • Pull with Rebase: git pull –rebase origin main

GNS3 Knowledge Base

Discover a wealth of information and expert tips in our GNS3 Knowledge Base, your go-to resource for mastering network simulations. Whether you need detailed tutorials, expert tips, or troubleshooting advice, our Knowledge Base has everything to enhance your skills and solve any challenges. Dive in now to enhance your skills and troubleshoot any challenges with ease!

Share the Knowledge: Spread the Word About Our Git Cheat Sheet!

If you find this page helpful for your networking knowledge and skills, please consider sharing it with your friends, colleagues, and social media followers. Your support helps us create more valuable resources and enhance our courses.

You can share this page on your social media accounts like Facebook, LinkedIn, Twitter, and any related networking and programming forums or blogs. By sharing, you assist other networking enthusiasts in their learning journey, making their work easier and more efficient. So, if you’d like to help others, kindly share this page.

For more in-depth networking knowledge, visit our route2open courses.

GIT Cheat Sheet!

Simply provide us with your name and email address, and we’ll send you our cheat sheet straight to your inbox