This content originally appeared on DEV Community and was authored by Advait Shukla
Ever found yourself asking…
- What exactly is Git, and why do developers swear by it?
- Is GitHub just cloud storage for code?
- How do teams collaborate on the same codebase without chaos?
- What’s a pull request or a fork? And why are people ‘starring’ repositories?
- How can GitHub Copilot help me write code faster?
If yes, then this blog is your go-to beginner’s guide. Let’s unravel the magic behind Git and GitHub, step-by-step, from installation to collaboration.
What Is Git?
Git is a version control system i.e it is a tool that helps you track changes in your code, go back to previous versions, and collaborate without losing your work.
Imagine working on a document where every edit is saved, and you can jump between versions, create alternate drafts (branches), and even merge others’ suggestions. That’s Git!
What Is GitHub?
GitHub is a cloud-based platform built around Git. It allows you to store, share, and collaborate on Git repositories with anyone around the world.
Think of GitHub as social media for developers:
- You “follow” projects.
- You “star” repositories you like.
- You “fork” them to customize your own version.
- You open “issues” to report bugs or suggest features.
- And you raise “pull requests” to contribute to others’ work.
Basic Git & GitHub Terminologies
Before we dive into hands-on steps, let’s understand some common terms you’ll see frequently when working with Git and GitHub:
Repository (Repo)
A repository is like a folder that contains all your project files and the entire history of changes made to those files. It can be local (on your computer) or remote (on GitHub).
Commit
A commit is a snapshot of your project at a specific point in time. Think of it like hitting “save” with a message explaining what you changed.
Push /
Pull
-
Push
: Sends your changes from your local machine to the GitHub repository. -
Pull
: Fetches the latest changes from the GitHub repo to your local machine.
Branch
A branch is a separate version of your code where you can experiment without affecting the main codebase. Developers often use branches to work on new features or fix bugs.
Merge
When you’re happy with the changes in your branch, you can merge it into the main branch to include those updates in the final project.
Fork
Forking a repo means copying someone else’s GitHub repository to your own account. It’s commonly used when you want to contribute to open-source projects.
Star
Starring a repository means you like it or want to bookmark it for later. It’s similar to “liking” a post.
Pull Request (PR)
When you make changes in your fork or branch and want to merge them into the original repository, you create a Pull Request. The owner can review, suggest changes, and approve it.
Issues
Issues are used to report bugs, suggest enhancements, or ask questions related to the project. They help manage collaboration and improvements.
GitHub Copilot
GitHub Copilot is an AI-powered tool (developed by GitHub & OpenAI) that suggests code in real time inside your code editor. It helps you write code faster and learn along the way.
Setting Up Git on Your Machine
On Your Command Prompt or VS code Terminal
Step 1: Install Git
Windows: Download Git git-scm.com
macOS: brew install git
Linux: sudo apt install git
Step 2: Verify Installation
git --version
Step 3: Set Your Identity
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
Let’s Set-up Your First Git Repository
Step 1: Create a Project Folder
mkdir my-first-project
cd my-first-project
Step 2: Initialize Git
git init
Step 3: Add a File
echo "# My First Git Project" > README.md
This creates a file named README.md and prints “# My First Git Project” on your terminal.
Step 4: Stage & Commit
git add .
git commit -m "Initial commit"
Step 5: Create Repository on GitHub
Go to GitHub
Click + > New Repository
Name it my-first-project and click Create Repository
Connect local project to remote
git remote add origin https://github.com/yourusername/yourrepo.git
git branch -M main
git push -u origin main
here yourrepo = my-first-project
Git Basics
git init #Initialize a Git repository
git status #Check the status of your repo
git add . #Add current files to staging or
git add <file> # Stage file for commit
git commit -m "message" # Commit changes
git log # View commit history
git pull # Fetch and merge from remote
git push # Push changes to GitHub
git branch # List branches
git checkout -b new-branch # Create & switch branch
Common Workflows
Clone a repository
git clone https://github.com/username/repo.git
Push changes to GitHub
git add .
git commit -m "Your message"
git push origin main
- Pull updates
git pull origin main
Pro Tips
Write clear commit messages
Use.gitignore
to skip unnecessary files
Create branches for new features: git checkout -b new-feature
Finally
Git and GitHub might seem intimidating, but once you start using them regularly, you’ll feel confident managing and collaborating on projects.
Whether you’re building your portfolio, contributing to open-source, or working in a team, Git is now your best friend.
Ready to Level Up?
Start Your GitHub Journey Today!
Start using GitHub Copilot to write code faster, explore inspiring open-source projects, and contribute like a pro with your own issues and pull requests. Whether you’re fixing bugs, collaborating with peers, or building your next portfolio project on your GitHub playground.
Got questions or want to dive deeper?
Linkedin
Feel free to DM or connect with me to learn more about:
- Unlocking the GitHub Student Developer Pack
- Real-world Git/GitHub scenarios
- Collaboration best practices
- Hosting your portfolio with GitHub Pages
Let’s build together and grow together.
Happy Coding!
This content originally appeared on DEV Community and was authored by Advait Shukla