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

git-cheatsheet-for-beginners

This document is a beginner's guide to using Git, covering essential commands and configurations. It includes instructions for checking the installed version, setting up user information, creating repositories, and managing file statuses. Additionally, it provides tips for streamlining workflows and avoiding repeated credential prompts during Git operations.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

git-cheatsheet-for-beginners

This document is a beginner's guide to using Git, covering essential commands and configurations. It includes instructions for checking the installed version, setting up user information, creating repositories, and managing file statuses. Additionally, it provides tips for streamlining workflows and avoiding repeated credential prompts during Git operations.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Page 1

git
FOR ABSOLUTE
Beginners
Download from: Created by:
git-scm.com courses.davegray.codes

Check installed version: YouTube Channel:


git --version @DaveGrayTeachesCode
git -v

Config settings:
git config --global user.name "Your Name" File >> Preferences >> Settings
"exclude"
git config --global user.email "[email protected]" Files:Exclude --> Remove **/.git

git config --global init.defaultBranch main

Help: Remove git from folder:


git help <command> rm -rf .git
Example: git help config Example: When using tutorial code
Download Code for a Tutorial:
git clone <url-from-github>
Example: git clone https://github.com/gitdagray/css_course.git
Page 2

git
FOR ABSOLUTE
Beginners
Create new repo: Created by:
git init courses.davegray.codes

Check repo status: YouTube Channel:


git status @DaveGrayTeachesCode
git status -s

Add files to repo: Commit file changes:


git add <filename> git commit -m "Short message"
Example: git add index.html Combine add & commit:
Add ALL files with: git add . git commit -a -m "Short message"

Discard Changes: Unstage a new added file:


git restore <filename> git rm --cached <filename>
Link a local repo to GitHub: Unstage a previously modified file:
git remote add origin <gh-url> git restore --staged <filename>
git branch -M main
git push -u origin main
Page 3

git
FOR ABSOLUTE
Beginners
Created by: YouTube Channel:
courses.davegray.codes @DaveGrayTeachesCode
Untracked File Status:
Files not yet added to repository.
VS Code displays a U beside the filename.

Unmodified File Status:


Tracked files that have not been changed.

Modified File Status:


Tracked files that have been changed.
VS Code displays an M beside the filename.

Staged File Status:


Tracked files that have been added.
VS Code displays an A beside the filename.

Ignored File Status:


Files that match a pattern or exact match in .gitignore
VS Code grays out the filename.
Page 4

git
FOR ABSOLUTE
Beginners
Created by: YouTube Channel:
courses.davegray.codes @DaveGrayTeachesCode
Basic Workflow in Git:
1. Create new files or make changes to existing files.
2. git commit -a -m "Short detail message about changes"
3. git push (to send code updates to GitHub repo)

Keep Git from Asking for Credentials with every git push:
git config --global credential.helper 'cache --timeout=3600'

You might also like