What is Version Control?
Version Control, also known as Source Control, is a system that helps you manage code efficiently.
version control allows you to:
> Track your files
> Revert your files to previous versions
CVCS vs DVCS:
There are two main types of version control systems:
> CVCS – Centralized Version Control System
> DVCS – Distributed Version Control System
Git is based on DVCS, meaning every developer has a local copy.
Git Advantage:
> Works with a local copy of the repository and commit changes locally.
Git Lifecycle: The Three States
A file in Git can be in one of three states:
1. Modified – The file has been changed but not yet tracked.
2. Staged – The changes are marked for the next commit (like a temporary area before committing).
3. Committed – The changes are saved in your local Git database.
Steps to Commit:
Step 1: Add the files
git add
Step 2: Commit the changes with a message
git commit -m "your commit message"
Step 3: Push changes to the repository
git push origin
Create a Local Git Repository:
git init
git add ML.txt
git commit -m "Added Personal Details"
Creating a Personal Repository on GitHub:
Step 1: Go to GitHub
Step 2: Click on New Repository
Step 3: Name your repository
Step 4: Add Description
Step 5: Choose visibility (public/private)
Step 6: Click Create repository
git config --global user.username "harinimadura06"
git config --global user.email "harinimadura06@gmail.com"
git remote add origin https://github.com/harinimadura06/24MCR030.git
git branch -M main
git push -u origin main
git add ML.txt
git commit -m "updated the personal details"
git push -u origin main
To Conclude:
Understanding Git and GitHub helps you manage your codebase efficiently but also makes collaboration smooth and structured.
Happy version controlling!
Top comments (0)