What is Git &GitHub and using it

What is Git?

Git is a distributed version control system that:

Tracks changes in your code/files over time

Enables collaboration between developers

Allows branching/merging of code

Maintains a full history of all changes


Key Git Concepts


Repository :

A project folder tracked by Git

Commit:
A saved snapshot of your changes

Branch:
Parallel version of your code

Merge:
Combining changes from different branches

Clone:
Copying a repository to your local machine

What is GitHub

GitHub is a cloud-based hosting service for Git repositories that adds.

Web interface for repositories
Pull requests and code review tools
Issue tracking and project management
Free public repositories (private repos require paid plan)

Getting Started with Git:

Install Git

# Linux (Debian/Ubuntu)
sudo apt install git

# Mac (Homebrew)
brew install git

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

Basic Git Commands

# Initialize a new repository
git init

# Check status of files
git status

# Add files to staging area
git add filename.txt
git add .  # Add all changed files

# Commit changes
git commit -m "Descriptive message about changes"

# View commit history
git log


Working with GitHub

Create a repository on GitHub.com

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

Link your local repo:

git push -u origin main

Common GitHub Workflow

# Get latest changes
git pull origin main

# Create a new branch
git checkout -b feature-branch

# After making changes.

git add .
git commit -m "Implemented new feature"
git push origin feature-branch

Comments

Popular posts from this blog

Interview question for File and FTP Adapter

What is boot.properties file and how to create

SSL Exceptions in Admin Server and Node Manager.