Git is a distributed version control system used to track changes in code during softwarw development. it allows multiple devlopers to work on a project at the same time without overwriting each other's work.
Version control lets you:
- Save snapshots of your project
- Revert to previous versions
- Collaborate with others
- Track who made which changes and when
You can download Git from git-scm.com
After installation, open your terminal and type:
git --version
If it returns a version number, Git is installed!
Initializing a Repository
To start using Git in a project folder:
git init
This creates a hidden .git folder that tracks your changes.
git add .
git commit -m "Iniitial commit"
git add .
stages all changes
git commit
saves them with a message
You can copy an existing repo to your machine using:
git clone http://github.com/username/repo-name.git
After linking your local project to a GitHub repo:
git remote add origin https://github.com/username/repo.git
git push -u origin main
This upload your work to GitHub.
Basic Commands Cheat Sheet
git status
-check what's going on
git log
-view comit history
git diff
-see changes made
git pull
-download changes
git push
-upload changes