The Mobarmeg turns your digital vision into reality with expert services in branding, marketing, and app development. Our commitment to innovation and tailored solutions ensures that your brand stands out in a competitive digital landscape, whether you're a startup or an established business
Complete Guide to Using Git and GitHub
Git and GitHub are essential tools for any modern developer. In this lesson, we will cover everything about Git and GitHub, from basics to advanced commands with practical examples. Let's get started!

What Are Git and GitHub?
Git is a version control system that allows you to track changes in your code over time. GitHub is a hosted platform that uses Git for collaboration and project sharing
Installing Git and Initial Setup
To download Git, visit the following link and install the appropriate version for your operating system:Download Here
- After installation, verify the installation by running:
git --version
Initial Setup
- Set your username and email:
git config --global user.name "your-username" git config --global user.email "your.email@example.com"
- Verify the configuration:
git config --list
Basic Commands for Managing Projects
- Initialize a New Repository:
git init
- Track Files:
git add .
- Save Changes:
git commit -m "Added a new feature"
- Check the Status:
git status
- View Commit History:
git log
Collaborating with GitHub
- Connect to a Remote Repository:
git remote add origin https://github.com/username/repo.git
- Push Changes:
git push -u origin master
- Pull Updates:
git pull origin master
- Clone a Repository:
git clone https://github.com/username/repo.git
Advanced Git Commands
- Create and Switch Branches:
Branches allow you to work on new features or fixes without affecting the main codebase. To create a new branch, use:
git branch branch_name
To switch to the new branch, use:
git checkout branch_name
Once done, merge the branch with the main branch:
git merge branch_name
- Handling Mistakes:
If you made changes to a file and want to undo them, use:
git checkout -- file_name
To remove the last commit but keep the changes, use:
git reset --soft HEAD~1
- Working with Stashes:
Stashes allow you to temporarily save changes if you need to switch to another task. To save changes, use:
git stash
To retrieve the saved changes, use:
git stash apply
- Deleting Branches:
If you need to delete a local branch after completing it, use:
git branch -d branch_name
To delete a branch on GitHub, use:
git push origin --delete branch_name
Practical Project for the Lesson
To complete this lesson, perform a practical project using the commands you learned:
- Create a new repository locally
- Add a README.md file with a project description
- Push the project to GitHub
- Create a new branch and make changes
- Merge the new branch with the main branch
And with that, we've wrapped up today's lesson. We learned Git & GitHub and covered most of the commands we might need