Skip to main content

Git Cheat Sheet

 

Git Cheat Sheet




CategoryCommandDescription
Setupgit config --global user.name "[name]"Set a name that will be attached to your commits and tags.
git config --global user.email "[email]"Set an email that will be attached to your commits and tags.
git initInitialize a new git repository in the current directory.
git clone [url]Clone a repository into a new directory.
Stage & Snapshotgit statusShow modified files in the working directory, staged for your next commit.
git add [file]Add a file as it looks now to your next commit (stage).
git reset [file]Unstage a file while retaining the changes in the working directory.
git diffShow diff of what is changed but not staged.
git diff --stagedDiff of what is staged but not yet committed.
git commit -m "[message]"Commit your staged content as a new commit snapshot.
Branch & Mergegit branchList all of the branches in your repo.
git branch [name]Create a new branch at the current commit.
git checkout [branch]Switch to another branch and check it out into your working directory.
git merge [branch]Merge the specified branch’s history into the current one.
git logShow all commits in the current branch’s history.
Share & Updategit remote add [alias] [url]Add a git URL as an alias.
git fetch [alias]Fetch down all the branches from that Git remote.
git merge [alias]/[branch]Merge a remote branch into your current branch to bring it up to date.
git push [alias] [branch]Transmit local branch commits to the remote repository branch.
git pullFetch and merge any commits from the tracking remote branch.
Inspect & Comparegit log --follow [file]Show the commits that changed file, even across renames.
git diff [branchB]...[branchA]Show the diff of what is in branchA that is not in branchB.
git show [SHA]Show any object in Git in human-readable format.

This table summarizes the most frequently used Git commands, providing a quick reference to manage your projects efficiently. Whether you're new to Git or need a quick refresher, this cheat sheet is a valuable tool for your development workflow.

Comments

Popular posts from this blog

DevOps Vs DevSecOps

   DevOps and DevSecOps are two methodologies that have gained traction in the IT industry for streamlining software development and deployment. However, their approach to security and operations differs, making each suitable for different types of projects and organizational needs. Let's explore DevOps versus DevSecOps with a real-time example, focusing on their distinctions, integration, and practical applications. DevOps: The Foundation DevOps is a cultural and professional movement that emphasizes collaboration and communication between software developers and other IT professionals while automating the process of software delivery and infrastructure changes. It aims to shorten the development life cycle and provide continuous delivery with high software quality. Core Principles: Continuous Integration and Continuous Deployment (CI/CD): Automate building, testing, and deployment of applications. Collaboration: Breaking down silos between teams (developers, IT operations...

Deploying a Node.js project to Azure App Services using Azure DevOps pipelines

Deploying a Node.js project to Azure App Services using Azure DevOps pipelines is a robust way to automate deployment processes and integrate continuous integration and deployment (CI/CD) practices into your workflow. This guide will walk you through the setup of an Azure DevOps pipeline to deploy a Node.js application from GitHub or Azure Repos to Azure App Services. Prerequisites Before you begin, ensure you have the following: An Azure account. You can sign up for a free account here . A GitHub or Azure Repos account with your Node.js project. An Azure DevOps account. Create one here if you don't have it. Step 1: Prepare Your Node.js Application Make sure your Node.js application is ready and includes a package.json file in the root. This file is crucial as it contains dependency information and scripts needed for your application. Step 2: Create an Azure Web App Log into Azure Portal: Visit https://portal.azure.com . Create a Web App: Click on "Create a resource". ...