Monday, December 22, 2025

thumbnail

Getting Started with Git and GitHub

 Getting Started with Git and GitHub


Git and GitHub are essential tools for modern software development. Git is a version control system, while GitHub is a platform for hosting and collaborating on Git repositories.


1. What Is Git?


Git is a tool that:


Tracks changes in files


Maintains version history


Allows multiple people to work on the same project


Helps you revert to previous versions if needed


Git works locally on your computer.


2. What Is GitHub?


GitHub is a cloud-based platform that:


Hosts Git repositories online


Enables collaboration through pull requests


Provides issue tracking and project management


Supports code reviews and CI/CD integrations


GitHub works with Git but is not the same thing.


3. Installing Git

Windows


Download from: https://git-scm.com


Use default installation options


macOS

brew install git


Linux

sudo apt install git



Check installation:


git --version


4. Basic Git Configuration


Set your username and email:


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

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


5. Creating Your First Git Repository

Initialize a Repository

git init


Check Repository Status

git status


6. Git Workflow Basics

Add Files to Staging Area

git add file.txt

git add .


Commit Changes

git commit -m "Initial commit"


View Commit History

git log


7. Working with Branches


Branches allow you to work on features independently.


Create a Branch

git branch feature-1


Switch Branch

git checkout feature-1



Or in one command:


git checkout -b feature-1


8. Connecting Git to GitHub

Step 1: Create a Repository on GitHub


Log in to GitHub


Click New Repository


Copy the repository URL


Step 2: Add Remote Repository

git remote add origin https://github.com/username/repo.git


Step 3: Push Code to GitHub

git push -u origin main


9. Cloning a Repository

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


10. Pulling and Pushing Changes

Pull Latest Changes

git pull origin main


Push Your Changes

git push origin main


11. Pull Requests (PRs)


Pull requests allow you to:


Propose changes


Review code


Merge changes into the main branch


Workflow:


Create a branch


Make changes


Push branch


Open a Pull Request on GitHub


12. Common Git Commands Summary

Command Purpose

git init Initialize repo

git clone Copy repo

git add Stage files

git commit Save changes

git status Check state

git pull Get updates

git push Send changes

13. Best Practices


Commit small, meaningful changes


Write clear commit messages


Use branches for new features


Pull frequently to avoid conflicts


Add .gitignore files


Conclusion


Git and GitHub help you manage code efficiently and collaborate with others. Learning these tools is essential for developers, data scientists, and DevOps engineers.

Learn Full Stack JAVA Course in Hyderabad

Read More

๐Ÿ› ️ Tools & Version Control

NoSQL vs SQL – What’s the Difference?

Spring Data JPA for Database Access

SQL Joins Simplified for Beginners

Visit Our Quality Thought Institute in Hyderabad

Get Directions 

Subscribe by Email

Follow Updates Articles from This Blog via Email

No Comments

About

Search This Blog

Powered by Blogger.

Blog Archive