In this HashiQube DevOps lab, you'll get hands-on experience with Git, the world's most popular version control system.
Git is a free and open-source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. It's easy to learn, has a small footprint, and offers lightning-fast performance.
Git outperforms traditional SCM tools like Subversion, CVS, Perforce, and ClearCase with powerful features such as:
- Efficient local branching
- Convenient staging areas
- Flexible workflows
- Distributed development model
To make working with Git even easier, you can use GitHub Desktop, a user-friendly Git client that simplifies your development workflow.
GitHub Desktop helps you:
- Focus on your work instead of fighting with Git syntax
- Visualize changes with an intuitive interface
- Easily switch between branches
- Simplify common Git tasks with a few clicks
- Perfect for both beginners and experienced users
To help you quickly learn the most common Git commands, here's a handy cheat sheet you can use as a wallpaper:
# Initialize a new Git repository
git init
# Clone an existing repository
git clone https://github.com/username/repository.git
# Check status of your working directory
git status
# Add files to staging area
git add filename.txt # Add specific file
git add . # Add all files
# Commit changes
git commit -m "Descriptive message"
# Commit all tracked changes without a separate add step
git commit -am "Descriptive message"
# List all branches
git branch
# Create a new branch
git branch branch-name
# Switch to a branch
git checkout branch-name
# Create and switch to a new branch in one command
git checkout -b branch-name
# Merge a branch into your current branch
git merge branch-name
# Add a remote repository
git remote add origin https://github.com/username/repository.git
# Push changes to remote
git push origin branch-name
# Pull changes from remote
git pull origin branch-name
# Fetch changes without merging
git fetch origin
- Create a branch for a new feature:
git checkout -b new-feature
- Make changes and commit:
git commit -am "Add new feature"
- Push to remote:
git push origin new-feature
- Create a pull request for review
- Merge into main branch after approval
main
branch contains production codedevelop
branch for ongoing development- Feature branches for new features
- Release branches for release preparation
- Hotfix branches for urgent production fixes
- Git Official Website
- Pro Git Book - Comprehensive free online book
- GitHub Learning Lab - Interactive tutorials
- Git Cheat Sheet by GitHub
- Learn Git Branching - Interactive visualization tool
- Oh Shit, Git!?! - Helping you fix Git mistakes