0% found this document useful (0 votes)
163 views1 page

Git Cheatsheet Single Page

This document provides a Git cheat sheet with commands for initializing a Git repository, branching, staging files, committing changes, and collaborating/sharing code. It lists common Git commands used for version control and working with others on software projects managed with Git. The cheat sheet acts as a quick reference for basic Git workflows and includes brief explanations of initializing a repo, branching, adding and removing files from the staging area, committing changes, pushing/pulling from remote repositories, and viewing diffs between commits/branches.

Uploaded by

ADab ADny
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
163 views1 page

Git Cheatsheet Single Page

This document provides a Git cheat sheet with commands for initializing a Git repository, branching, staging files, committing changes, and collaborating/sharing code. It lists common Git commands used for version control and working with others on software projects managed with Git. The cheat sheet acts as a quick reference for basic Git workflows and includes brief explanations of initializing a repo, branching, adding and removing files from the staging area, committing changes, pushing/pulling from remote repositories, and viewing diffs between commits/branches.

Uploaded by

ADab ADny
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Git Cheat Sheet Updated 8/13/20

Git Cheat Sheet

Git is an open source version control system that works locally to help developers work

together on software projects that matter. This cheat sheet provides a quick reference to

commands that are useful for working and collaborating in a Git repository (repo).

Initializing Branching

Starting up Git within a project and getting it connected. Isolating work and managing feature development in one

place.
git init

Initializes (or starts) your current working directory (folder) as a Git git branc h

repository (repo). Lists all current branches. An asterisk ( ) will appear next to your
*

currently active branch.


git clone https://www.github.com/username/repo-name

Copies an existing Git repo hosted remotely. git br anc h new-branch

Creates a new branch. You will remain on your currently active


git remote or git remote -v
branch until you switch to the new one.
Shows your current Git directory’s remote repo. Use the -v flag for

more info. git checko ut another-branch

Switches to any existing branch and checks it out into your


git remote add upstream
current working directory.
https://www.github.com/username/repo-name

Adds the Git upstream to a URL. git checko ut -b new-branch

Consolidates the creation and checkout of a new branch.

Staging git br anc h - d branch-name

Creating files staged after modifying a file and marking it Deletes a branch.

ready to go in the next commit.

git status C ollabo rating an d Sharing

Checks the status of your Git repo including , files added that are Downloading changes from another repository or sharing

not staged. changes with the larger codebase.

git add . or git add my_script.js git pus h origin main

Stages modi fied files. If you make changes that you want included Pushes or sends your local branch commits to the remote repo. 

in the next commit, you can run add again. Use “git add .” for all No :te some repos use master instead of main in their commands.

files to be staged, or specify specific files by name.


git pull
git re set m y_script.js Fetches and merges any commits from the tracking remote

Removes a file from staging while retaining changes within your branch.

working directory.

git merge upstream/main

Merges the fetched commits.

C ommitting
Recording changes made to the repo.
Sh owing Changes
git commit "Commit message"
-m See changes between commits branches and more. , ,
Commits staged files with a meaningful commit message so that

you and others can track commits.


git diff -- staged
Compares modi fied files that are in the staging area.
git commit - am "Commit message"
Condenses all tracked files by committing them in one step. git diff a-branch ..b-branch
` ` `
Displays the diff of what is in a-branch but is not in b-branch . `
git commit -- amend -m " New commit message "
Modi fies your commit message. git diff 61ce3e6..e221d9c
Uses commit id to show the diff between two speci fic commits.

Follow us twitter digitalocean facebook DigitalOceanCloudHosting Linkedin DigitalOcean

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy