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