Skip to content

Git101 is your beginner-friendly guide to mastering Git and GitHub. Learn version control fundamentals through clear explanations, practical exercises, and real-world examples. Empower your coding journey and collaboration skills with this comprehensive resource.

License

Notifications You must be signed in to change notification settings

RedHatRanger/Git101

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

image

🚀 Git101: Let's Get Started with Git! (5th Grader Edition)

Hey there, future Git expert! Welcome to Git101 Labs, where you'll learn how to use Git and have fun while doing it! 🎉

What's Inside?

Inside this Git101 repository, you'll find:



Other Useful Information

🐧 Make Git Show Your Branch in Linux

image

Want to see what Git branch you're on every time you use the terminal? Add this magic spell to your ~/.bashrc:

For RHEL, Fedora, Rocky, Centos Varieties

source /usr/share/git-core/contrib/completion/git-prompt.sh
export GIT_PS1_SHOWDIRTYSTATE=true
export GIT_PS1_SHOWUNTRACKEDFILES=true
export PS1='[\u@\h \W$(declare -F __git_ps1 &>/dev/null && __git_ps1 " (%s)")]\$ '

Then run:

source ~/.bashrc

For Debian, Ubuntu, Arch, etc. Varieties

curl -o ~/.git-prompt.sh https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh

Then add this to your ~/.bashrc

source ~/.git-prompt.sh
export GIT_PS1_SHOWDIRTYSTATE=true
export GIT_PS1_SHOWUNTRACKEDFILES=true
export PS1='[\u@\h \W$(declare -F __git_ps1 &>/dev/null && __git_ps1 " (%s)")]\$ '

Then run:

source ~/.bashrc

Now, your terminal will always tell you what Git branch you're on! 🌟




🖥️ Make Git Show Your Branch in Windows

image

Want your PowerShell to tell you what branch you're on? Follow these steps:

1️⃣ Open Notepad 📝
2️⃣ Copy and paste the text below into Notepad.
3️⃣ Save it as setup-posh-git.ps1 or something cool.
4️⃣ Right-click and Run As Administrator!

# 🚀 Show Git Branch Names in PowerShell with Posh-Git

# Step 1: Set Execution Policy (Needs Admin Privileges)
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser -Force

# Step 2: Install Posh-Git (Requires Internet Connection)
Install-Module posh-git -Scope CurrentUser -Force

# Step 3: Ensure PowerShell Profile Exists
if (!(Test-Path $PROFILE)) {
    New-Item -ItemType File -Path $PROFILE -Force
}

# Step 4: Add Posh-Git to PowerShell Profile
$profileContent = Get-Content $PROFILE -Raw
if ($profileContent -notmatch "Import-Module posh-git") {
    Add-Content -Path $PROFILE -Value "`nImport-Module posh-git`n"
}

# Step 5: Reload the PowerShell Profile
. $PROFILE

Write-Host "🎉 Posh-Git is installed! Restart PowerShell to see Git branch names in your prompt." -ForegroundColor Green

Now, every time you open PowerShell, you'll see your Git branch right in the prompt! 🚀✨

Time to start coding like a Git pro! 🏆



Next: Lab 1 - Git Setup and Basic Workflows

About

Git101 is your beginner-friendly guide to mastering Git and GitHub. Learn version control fundamentals through clear explanations, practical exercises, and real-world examples. Empower your coding journey and collaboration skills with this comprehensive resource.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published