DEV Community

zipporahmutanu04
zipporahmutanu04

Posted on

πŸš€Day 2: Git & GitHub Essentials – Forking, Collaboration, PRs & More!

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
Enter fullscreen mode Exit fullscreen mode

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.

Image description
βœ… You now have your own copy to work with freely.

🀝 Step 2: Cloning & Setting Up Collaboration

🎯 Goal: Download your forked repo to your computer.

Image description
πŸ“ Steps:

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.

Image description
βœ… 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
Enter fullscreen mode Exit fullscreen mode

βœ… 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
Enter fullscreen mode Exit fullscreen mode

βœ… 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
Enter fullscreen mode Exit fullscreen mode

βœ… 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 

Enter fullscreen mode Exit fullscreen mode

πŸ’¬ 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)

Collapse
 
msnmongare profile image
Sospeter Mong'are

Well written article