What are Git and GitHub?
Git is a distributed version control system used to manage and track changes in source code during software development.
GitHub is a platform that hosts Git repositories online, making it easier for teams to collaborate, review code, and manage version control.
How to Install Git
Linux
sudo apt update
sudo apt install gitWindows
Download Git from git-scm.com and run the installer.
macOS
brew install gitConfiguring Git
Step 1: Set Username
git config --global user.name "Your Name"Step 2: Set Email
git config --global user.email "your.email@example.com"Basic Git Commands
Initialize a Repository
git initCheck the Status of Your Repository
git statusAdd Files to Staging
git add filename
git add .Commit Changes
git commit -m "Your commit message"View Commit History
git logConnecting Git with GitHub
Step 1: Create a New Repository on GitHub
Go to GitHub, create a new repository, and name it as desired. Copy the repository URL.
Step 2: Link Your Local Repository to GitHub
git remote add origin https://github.com/username/repository-name.gitStep 3: Push Changes to GitHub
git push -u origin masterBasic Workflow with Git and GitHub
- Make changes: Modify your files locally.
- Stage changes: Add files with
git add. - Commit: Save changes with a descriptive message using
git commit. - Push: Upload changes to GitHub using
git push. - Pull: Sync your local repository with updates from GitHub using
git pull.