0% found this document useful (0 votes)
46 views

Git Cheat Sheet: Install & Update Git Track Changes

The document is a Git cheat sheet that provides concise instructions for common Git commands and workflows. It covers how to install and update Git, initialize and clone repositories, track changes, commit changes and view commit history, configure user details, ignore files, delete and replace files, and host repositories on GitHub. The cheat sheet acts as a quick reference guide for the basic yet essential Git functions.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views

Git Cheat Sheet: Install & Update Git Track Changes

The document is a Git cheat sheet that provides concise instructions for common Git commands and workflows. It covers how to install and update Git, initialize and clone repositories, track changes, commit changes and view commit history, configure user details, ignore files, delete and replace files, and host repositories on GitHub. The cheat sheet acts as a quick reference guide for the basic yet essential Git functions.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Git Cheat Sheet

www.codesweetly.com

Install & Update Git Track Changes


How to install and update Git on your system How to monitor changes to files or folders

Install Git https://git-scm.com/download Check File Status git status

Check Git’s Installation which git Stage Specific File (or git add <fileOrFolderName>
Location Folder)

Check Installed Git git --version Replace


Version <fileOrFolderName> with
the file (or directory)’s
pathname
Update Git (Windows) git update-git-for-windows

Stage All Modified and git add -A


Update Git (Mac) https://git-scm.com/download/mac
Untracked Files

The -A flag is a shorthand


for --all

Initialize & Clone Git Stage Current Directory’s git add .


Modified and Untracked
How to initialize a new local Git repository or clone an existing Files
Git repository

Initialize Git A dot symbol means


git init
“current directory”

Clone a Git Repository git clone <theGitRepoURL> <where


Stage All Modified Files git add -u
to save the cloned git folder>
That You’ve Committed
Previously

The -u flag is a shorthand


for --update
Configure Git
Compare Working git diff
How to configure, review, and update user information for all Directory and Staging
local Git repositories Area’s File Versions

Configure Your Git git config --global user.name “Your


Details (E.g., Username) Name” Compare Staging Area’s git diff --staged
File Version with the Most
Recently Committed
Configure Your Git git config --global user.email “your- Version
Details (E.g., Email) [email protected]

Check Project’s git config --list


Configurations

Check Specific git config user.email


Undo Staging
Configuration (E.g., How to undo staged files
username)
Undo the Staging of a git reset HEAD fileToUnstage
Change Your git config user.name “The New Specific File
Configuration (E.g., Name”
Username) Undo the Staging of All git reset
Files
Change Your git config user.email “the-new-
Configuration (E.g., [email protected]
Email)

Exit Git Configuration Press the Q keyboard key


Space

Visit codesweetly.com/how-to-use-git for more information on Git


Git Cheat Sheet
www.codesweetly.com

Commit & Check Commit Ignore Files


History How to tell Git to ignore specific files

How to save and check files previously saved to the Git Create a .gitignore touch .gitignore
File
repository

Commit Files git commit -m “Write a message Example of a https://www.codesweetly.com/how-to-use-


about the file(s) you are committing” .gitignore File git/#example-of-a-gitignore-file

Commit Without git commit --amend --no-edit Open Gitignore’s git help gitignore
Writing a Commit Manual Page
Message

Change Last Commit git commit --amend


Message

Commit Without Staging


Delete Files & Folders
git commit -a
First How to delete files and folders from the working directory and
Git repository
See the Changes You git commit -v
Are about to Commit Delete File from the git rm fileToDelete
Working Directory and
the Git Repository
View Project’s Commit git log
History
Forcefully Delete File git rm -f fileToDelete
from the Working
View Specific Number of git log -3 Directory and the Git
the Project’s Commit Repository
History (E.g., Three)

Delete Folder from the git rm -r fileToDelete


Exit Git Console Space Press the Q keyboard key Working Directory and
the Git Repository
See All the Files git ls-files
Currently in the Staging Delete File Only from git rm --cached fileToDelete
Area and in the Git the Staging area—not
Repository from the Working
Directory
Check If a Specific File or git ls-files | grep
Folder Is in the Git <fileOrFolderName> Rename File git mv currentFileName newFileName
Directory

Replace a Working git checkout --


Replace Directory’s file with Its localFileToDeleteAndReplace
<fileOrFolderName> Last Committed
with the file (or Version
directory)’s pathname

Host Git Repository on https://www.codesweetly.com/how-


GitHub github-works#host-git-repository-on-github

Visit codesweetly.com/how-to-use-git for more information on Git

You might also like