Unraveling the World of Git ๐๐ฉโ๐ป
What's Git? ๐ค
Git is like a superhero for tracking changes to files! It helps you coordinate work among multiple people and revert back to earlier versions of files. Perfect for software development or any project with files.
Meet GitHub! ๐๐
GitHub, powered by Git, is the cool web-based platform where you can host, share, and collaborate on projects. It's the social hub for developers, and it adds its own awesome features to Git's functionalities.
Version Control Demystified ๐๐
Version control is like a time machine for files! It tracks changes so you can recall specific versions. There are two main types: Centralized (CVCS) and Distributed (DVCS).
CVCS has a central server. Examples: Subversion, Perforce.
DVCS allows you to clone the entire repository. Examples: Git, Mercurial, Darcs.
Why Go Distributed? ๐๐ฐ
DVCS, like Git, brings better collaboration, improved speed, greater flexibility, and enhanced security. It allows developers to work independently and merge changes seamlessly.
1: Git Setup ๐ ๏ธ
Install Git: Download Git
Create a GitHub account: Sign Up on GitHub
2: Learn Git Basics ๐๐ฉโ๐ซ
๐ Setting Up Git
Initialize a new Git repository:
git init
Clone a repository from GitHub:
git clone <repository_url>
๐ Basic Workflow
Check the status of your repository:
git status
Add changes to the staging area:
git add <file_name>
To add all changes:
git add .
Commit changes to the local repository:
git commit -m "Your commit message"
๐ฟ Branching
Create a new branch:
git branch <branch_name>
Switch to a branch:
git checkout <branch_name>
Or, combine branch creation and switching:
git checkout -b <new_branch_name>
โ๏ธ Merging
Merge changes from one branch into another:
git merge <source_branch>
๐ Remote Repositories (GitHub)
Add a remote repository:
git remote add origin <repository_url>
Push changes to a remote repository:
git push -u origin <branch_name>
๐ Updating and Retrieving Changes
Pull changes from a remote repository:
git pull origin <branch_name>
Fetch changes from a remote repository:
git fetch origin
๐ง Handling Conflicts
Resolve merge conflicts:
Manually edit the conflicted file.
Add changes to the staging area.
Commit the changes.
๐ Logging and History
View commit history:
git log
Or for a more concise view:
git log --oneline
3: Hands-on Exercises ๐คฒ๐ป
Create a new repository on GitHub.
Clone it to your local machine.
Make changes to a file and commit using Git.
Push changes back to GitHub.
Reflect on the Journey ๐ค๐
Day 8 introduced us to the superhero duo - Git and GitHub! Share your thoughts and experiences. How did your exercises go? Let's chat! ๐๐