Celebrating Achievements and Sharing Knowledge! ππ‘
Hey DevOps Enthusiasts! π Today marks the completion of our Linux & Git-GitHub hands-on journey. π I hope you've found it as exciting and enlightening as I have! π
Cheatsheet: Mastering Git Commands π
Git Essentials: Your Quick Reference Guide ππ
Installation & GUIs:
GitHub provides user-friendly installers for Git, ensuring you stay updated.
GitHub for Windows: Download Here
GitHub for Mac: Download Here
Git for All Platforms: Official Git Website
Setup:
Configure global user information for all local repositories:
git config --global user.name "[firstname lastname]" git config --global user.email "[valid-email]" git config --global color.ui auto
Setup & Init:
Initialize an existing directory as a Git repository:
git init
Clone a repository from a hosted location via URL:
git clone [url]
Stage & Snapshot:
View modified files in the working directory, staged for the next commit:
git status
Add a file to the staging area:
git add [file]
Commit your staged content:
git commit -m "[descriptive message]"
Branch & Merge:
List branches with an indicator for the active branch:
git branch
Create a new branch:
git branch [branch-name]
Switch to another branch:
git checkout [branch]
Merge the specified branch's history into the current one:
git merge [branch]
Inspect & Compare:
Show the commit history for the active branch:
git log
Show commits on branchA that are not on branchB:
git log branchB..branchA
Show the diff of what is in branchA that is not in branchB:
git diff branchB...branchA
Tracking Path Changes:
Delete a file from the project and stage the removal for commit:
git rm [file]
Change an existing file path and stage the move:
git mv [existing-path] [new-path]
Ignoring Patterns:
Configure system-wide ignore patterns for all local repositories:
git config --global core.excludesfile [file]
Create a .gitignore file with desired patterns.
Share & Update:
Add a Git URL as an alias:
git remote add [alias] [url]
Fetch branches from a remote:
git fetch [alias]
Merge a remote branch into the current one:
git merge [alias]/[branch]
Transmit local branch commits to the remote repository branch:
git push [alias] [branch]
Fetch and merge any commits from the tracking remote branch:
git pull
Rewrite History:
Apply commits of the current branch ahead of a specified one:
git rebase [branch]
Clear staging area, rewrite working tree from a specified commit:
git reset --hard [commit]
Temporary Commits:
Save modified and staged changes:
git stash
List stashed file changes:
git stash list
Apply changes from the top of the stash stack:
git stash pop
Discard changes from the top of the stash stack:
git stash drop
Reflect, Share, and Keep Learning! ππ
Let's celebrate our achievements, share our knowledge, and continue this incredible DevOps journey! ππ»