DEV Community

Cover image for Git - Github Quick Revision
Mehfila A Parkkulthil
Mehfila A Parkkulthil

Posted on

Git - Github Quick Revision

GitHub Fundamentals

What is Git?

Git is a version control system used to track changes in your files. It allows undo, restore, and manage multiple versions ,helps multiple people work on the same project without conflict .

What is GitHub?

GitHub is a cloud platform where you can store your Git repositories online.

Git = tool on your computer
GitHub = website to store/share projects

How to install Git

Open terminal/cmd:

git --version
Enter fullscreen mode Exit fullscreen mode

If not installed → download from official site.

Git Workflow Basics

Working directory → Staging → Repository
Enter fullscreen mode Exit fullscreen mode

Working Directory are your actual files.

Staging — files marked to be saved.

Repository — final saved version in .git

Git Commands

  1. Initialize Git
git init
Enter fullscreen mode Exit fullscreen mode
  1. Tell Git who you are
git config --global user.name "Your Name"
git config --global user.email "your@email.com"
Enter fullscreen mode Exit fullscreen mode
  1. Check status
git status
Enter fullscreen mode Exit fullscreen mode
  1. Add file(s) to staging
git add filename
Enter fullscreen mode Exit fullscreen mode

or
add everything(all files) at a time :

git add .
Enter fullscreen mode Exit fullscreen mode
  1. Commit (save) changes
git commit -m "Write a meaningful message"
Enter fullscreen mode Exit fullscreen mode

Branching

Create a branch:

git branch feature1
Enter fullscreen mode Exit fullscreen mode

To Switch to branch:

git checkout feature1
Enter fullscreen mode Exit fullscreen mode

Create + switch together:

git checkout -b feature1
Enter fullscreen mode Exit fullscreen mode

Merge branch:

git checkout main
git merge feature1
Enter fullscreen mode Exit fullscreen mode

Connecting Git to GitHub

Step 1: Create a new repository on GitHub

Do NOT initialize with README (optional but recommended)
Enter fullscreen mode Exit fullscreen mode

Step 2: Connect local repo to GitHub

git remote add origin https://github.com/yourusername/repoName.git
Enter fullscreen mode Exit fullscreen mode

Step 3: Push code to GitHub

git push -u origin main
Enter fullscreen mode Exit fullscreen mode

After first time:

git push
Enter fullscreen mode Exit fullscreen mode

Pulling and Cloning

Clone someone else’s repo:

git clone https://github.com/user/repo.git
Enter fullscreen mode Exit fullscreen mode

Pull (download new changes):

git pull
Enter fullscreen mode Exit fullscreen mode

GitHub Collaboration Basics

  • Fork → Your own copy of someone’s repo

  • Pull Request (PR) → Request to merge your changes

  • Issues → Report bugs or improvements

  • Actions → Automate tests/deployments

Top comments (0)