3 min-read Git Guidebook
A few words about Git
Git is essential for developers, providing robust version control and seamless project collaboration. In this article, we’ll take a journey to learn key Git commands. By the end, you’ll have a solid foundation in Git, enabling efficient code management and confident coding quests.
Let the adventure begin…
a. macOS:
# Use Homebrew enchanting magic to install Git
brew install git
# Verify the installation with a spell
git --version
b. Windows:
Embark on a quest to the official Git website (https://git-scm.com/downloads) and acquire the Git Installer.
Setting Your Git Identity:
# Configure your identity for legendary commits
git config --global user.name "Your Name"
git config --global user.email "your-email@example.com"
Building Your Code Kingdom: Creating a Git repository and claiming your coding realm
# Create a new directory for your project
mkdir MyProject
cd MyProject
# Initiate the Git
git init
# Gaze upon your newly claimed realm
git status
Tracking and Staging:
# Track and stage files with your Git radar
git add file1.txt file2.txt
# Channel your powers to stage all changes
git add .
Committing Changes:
# Cement your changes and add a memorable commit message
git commit -m "Commit message"
Branching and Merging:
# Summon a new branch into existence
git branch feature-branch
# Master the art of switching branches
git checkout branch-name
# Engage in epic branch battles and merge their powers
git merge branch-name
# Peek into Git's collection of branches, like a wise observer
git branch
Create a repository on GitHub (if not already created) and link it to the local repository
git remote add origin <GitHub_repository_URL>
Push the commit to the GitHub repository
git push -u origin master
Note: If your branch is not named master
, replace master
with the actual name of the branch.
git push -u origin main
Congratulations!
You’ve made it! From installing Git to pushing your code to a GitHub repository, you’ve embarked on a journey of mastering this powerful version control system. Stay tuned for the next article, where we’ll continue to learn the word of software development ✨