Skip to main content

HTML APIs

Getting Started with Git and GitHub

Getting Started with Git and GitHub: Version Control for Developers

Git and GitHub logos side by side

Git is an essential version control system for developers, and GitHub is the most popular platform for hosting Git repositories. Let's learn the basics.

1. Installing Git and Creating a GitHub Account

Install Git

  • Windows: Download from git-scm.com
  • Mac: Install via Homebrew (brew install git) or download
  • Linux: Use your package manager (sudo apt install git for Ubuntu)

Create GitHub Account

Visit github.com and sign up for a free account.

2. Basic Git Commands

Common Git commands cheat sheet

Initialize a repository

git init

Check status

git status

Add files to staging

git add filename
git add .  # Add all files

Commit changes

git commit -m "Your commit message"

3. Working with GitHub

Create a new repository on GitHub

Click the "+" button in the top right and select "New repository".

Connect local repository to GitHub

git remote add origin https://github.com/username/repository.git
git branch -M main
git push -u origin main

Clone an existing repository

git clone https://github.com/username/repository.git

Push changes to GitHub

git push origin main

Pull changes from GitHub

git pull origin main

Git and GitHub are powerful tools that will help you collaborate on projects and manage your code effectively. Practice these commands to become comfortable with version control!

Comments