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'