Hey everyone
Welcome back to Day 2 of my dev journey! Yesterday I shared how I set up my development environment. Today, I dove deep into something every developer needsβGit and GitHub. If youβve ever wondered whatβs the difference between a fork and a clone? or how to handle merge conflicts without panickingβthis is for you!
β 1.Why Git? Why GitHub?
Git helps you track your code history, collaborate easily, and avoid the fear of "what if I break something?".
GitHub is where your Git projects live online so others can contribute, comment, or review.
2. Basic Git Commands I Practiced
Use code blocks and explain them simply:
git init
git add .
git commit -m "Initial commit"
git remote add origin <your-repo-url>
git push -u origin main
lets get started,
π±
Step 1: Forking a Repository
π― Goal: Make a personal copy of a project to work on.
π Steps:
Go to the GitHub repo you want to contribute to.
Click the Fork button at the top-right.
A new copy appears in your GitHub account.
β
You now have your own copy to work with freely.
π€ Step 2: Cloning & Setting Up Collaboration
π― Goal: Download your forked repo to your computer.
Copy the repo URL from GitHub
git clone https://github.com/your-username/repo-name.git
Move into the folder
cd repo-name
β
Youβre ready to start working locally.
π± Step 3: Create a New Branch
π― Goal: Work in isolation from the main branch.
π Steps:
git checkout -b feature-branch-name
β Your changes are safe in this new branch.
βοΈ Step 4: Make Changes and Commit
π― Goal: Save your changes with a message.
π Steps:
Stage your changes
git add .
Commit with a message
git commit -m "Add feature or fix"
β
Your progress is recorded in Git history.
π Step 5: Push Changes to GitHub
π― Goal: Upload your changes online.
π Steps:
git push origin feature-branch-name
β
Now your changes are visible on your GitHub fork.
π Step 6: Create a Pull Request (PR)
π― Goal: Request to merge your changes into the original project.
π Steps:
Go to your fork on GitHub.
Click Compare & pull request.
Add a descriptive title and summary.
Click Create pull request.
β
Youβve asked the project owner to review and merge your work.
π Step 7: Code Review
π― Goal: Let collaborators check your work.
π Steps:
Reviewers may leave comments.
If changes are requested:
Make the fix
git add .
git commit -m "Fix review suggestions"
git push
β Code reviews help keep the project clean and consistent.
βοΈ Step 8: Resolve Merge Conflicts
π― Goal: Fix code clashes when multiple people edit the same line.
π Steps:
git pull origin main
If there's a conflict, Git will mark it like this:
<<<<<<< HEAD
your version
other version
main
Fix it manually, then:
git add .
git commit -m "Resolve merge conflict"
git push
β Merge conflict resolved.
β Step 9: Use GitHub Issues
π― Goal: Report bugs or suggest new features.
π Steps:
Go to the repo's Issues tab.
Click New Issue.
Describe the problem or idea clearly.
Submit it.
β A great way to manage and track tasks.
π§ͺ Step 10: Must-Know Git Commands
Command Description
git clone URL Copy project from GitHub
git status See what's changed
git add . Stage all changes
git commit -m "msg" Save changes
git push Upload to GitHub
git pull Fetch latest changes
git checkout -b branch Create new branch
β
Final Workflow Summary
1. Fork the repository
2. Clone to your computer
3. Create a new branch
4. Make and commit changes
5. Push changes to GitHub
6. Open a pull request
7. Collaborate through code reviews
8. Fix merge conflicts
9. Use issues for collaboration
10. Repeat as needed
π¬ Bonus Tip
π‘ Always run git pull before you push to avoid conflicts.
π― Use clear commit messages and PR titles to help your teammates.
Top comments (1)
Well written article