Sproutern LogoSproutern
Technical Skills

Git & GitHub for Beginners: Complete Guide 2025

Git is non-negotiable for developers. Learn the essential commands, workflows, and collaboration techniques you'll use every day.

Sproutern Career Team
December 14, 2025
25 min read

Key Takeaways

  • Git is version control; GitHub is a hosting platform
  • Commit early, commit often—good commits tell a story
  • Always work in feature branches, never directly on main
  • Pull requests are how teams review and merge code

1. Git Basics & Setup

What is Git?

Git is a distributed version control system. It tracks changes in your code, lets you collaborate with others, and provides a safety net to undo mistakes.

Initial Setup

# Configure your identity

git config --global user.name "Your Name"

git config --global user.email "you@email.com"

# Initialize a new repo

git init

2. Essential Commands

CommandPurpose
git statusSee changed files
git add .Stage all changes
git commit -m "msg"Save changes with message
git pushUpload to remote
git pullDownload latest changes
git logView commit history

3. Branching & Merging

Branches let you work on features without affecting the main codebase:

# Create and switch to new branch

git checkout -b feature/login-page

# Switch branches

git checkout main

# Merge branch into current

git merge feature/login-page

Branch Naming Conventions

  • feature/ - new features
  • bugfix/ - bug fixes
  • hotfix/ - urgent production fixes

4. GitHub Workflow

The Standard Workflow

  1. Clone the repo: git clone URL
  2. Create a feature branch
  3. Make changes and commit
  4. Push your branch to GitHub
  5. Create a Pull Request (PR)
  6. Get code reviewed and merge

5. Collaboration

Pull Request Best Practices

  • Keep PRs small and focused (one feature per PR)
  • Write descriptive PR titles and descriptions
  • Request reviews from relevant team members
  • Respond to feedback constructively
Pro Tip: Good commit messages follow this format: "Verb + what changed" (e.g., "Add user authentication", "Fix login bug", "Update README")

6. Pro Tips

  • Use .gitignore: Exclude node_modules, .env, and other files that shouldn't be tracked
  • Commit frequently: Small, logical commits are easier to review and debug
  • Pull before push: Always pull latest changes before pushing
  • Learn to resolve conflicts: They're inevitable—don't fear them

Advanced Git Commands

CommandPurpose
git stashTemporarily save uncommitted changes
git stash popRestore stashed changes
git rebase mainReapply commits on top of main
git cherry-pick <hash>Apply a specific commit
git reset --hard HEAD~1Undo last commit (destructive)
git reflogHistory of all Git operations
git bisectFind commit that introduced bug

Resolving Merge Conflicts

Conflicts happen when two branches modify the same lines. Here's how to handle them:

  1. Don't panic: Conflicts are normal
  2. Look for conflict markers: <<<<<<<, =======, >>>>>>>
  3. Choose which code to keep (or combine both)
  4. Remove the conflict markers
  5. Stage and commit: git add . && git commit
Pro Tip: VS Code has excellent built-in conflict resolution tools. Use "Accept Current", "Accept Incoming", or "Accept Both" buttons.

Common Git Mistakes

Committing directly to main

Always use feature branches. Protect main with branch rules.

Giant commits with vague messages

"Fixed stuff" tells nothing. Write descriptive commit messages.

Force pushing to shared branches

git push --force can destroy teammates' work. Never do it on shared branches.

Committing sensitive data

API keys, passwords, .env files should never be committed. Use .gitignore and check before every commit.

Not pulling before working

Always git pull before starting work. Prevents many conflicts.

Success Stories

"Git skills saved my internship interview..."

"Interviewer asked about my Git workflow. I explained branching, PRs, and code reviews. Got the job because I showed I could work in a team." — Rahul, IIT Bombay

"Green contribution graph got me noticed..."

"Made daily commits to my projects. Recruiter mentioned my GitHub activity during the interview. Showed consistency matters." — Priya, IIIT Hyderabad

"Learned to recover from disasters..."

"Accidentally deleted important code. Used git reflog to find the lost commit and restored everything. Git saved hours of work." — Karan, VIT Vellore

Frequently Asked Questions

What's the difference between Git and GitHub?

Git is the version control system (the tool). GitHub is a platform that hosts Git repositories online. Other alternatives include GitLab and Bitbucket.

How often should I commit?

Commit whenever you complete a logical unit of work. A good rule: if you can't describe the commit in one sentence, it's too big.

Should I use merge or rebase?

Merge is safer and preserves history. Rebase creates a cleaner history but can complicate things. For beginners, stick with merge.

How do I undo a commit?

Use git reset --soft HEAD~1 to undo but keep changes. Use git reset --hard HEAD~1 to completely remove (dangerous). git revert creates a new commit that undoes changes (safest).

What should go in .gitignore?

node_modules, .env files, build folders, IDE settings (.idea, .vscode), OS files (.DS_Store), and any generated files.

How do I contribute to someone else's repo?

Fork the repo to your account, clone your fork, make changes, push to your fork, then create a Pull Request to the original.

Git Mastery Checklist

Install Git and configure user.name and user.email
Create a GitHub account
Master basic commands: clone, add, commit, push, pull
Understand branching: create, switch, merge branches
Create your first Pull Request
Successfully resolve a merge conflict
Use git stash to save work temporarily
Write good commit messages consistently

GitHub Profile Optimization

  • Add a profile README: Create a repo named your username with a README.md that shows on your profile
  • Pin your best repos: Showcase 6 projects that demonstrate your skills
  • Keep your contribution graph green: Regular commits show consistency
  • Write good READMEs: Every project should have clear documentation
  • Add project descriptions: One-line summaries help visitors understand

Master Git for Your Career

Git is used in virtually every tech company. The more comfortable you are with it, the more effective you'll be as a developer.

Remember: everyone struggles with Git at first. The important thing is to keep practicing, and don't be afraid to make mistakes—that's what version control is for!

Start using Git in all your projects. Practice makes perfect. 🚀

Written by Sproutern Career Team

Practical Git knowledge for aspiring developers.

Last updated: December 14, 2025