Thursday, September 24, 2026

Git and GitHub Notes by Megha (Pg1)

Next »
# Git + GitHub Notes

### Git
- Distributed version control system.
- Works offline as well.

### Version Control Systems

**Centralized**
- All data is in one server.

**Distributed**
- Every developer has a copy.
- Changes can be made in the local repository and then pushed/shared.
- GitHub is an online platform where repositories are hosted.

### Steps — Install Git

1. Go to the folder location you want to track.
2. Open CMD:
   
   git --version
   
3. Check Git status:
   
   git status
   
4. Configure username:
   
   git config --global user.name "mayank"
   
5. Configure email:
   git config --global user.email "mayank@gmail.com"
   

### Git Workflow

**Working Directory → Staging Area → Local Repository → Remote Repository**

- Add:
  
  git add 
  

- Commit:
  
  git commit -m "..."
  

6. Example:
   
   git add index.css
   

7. Commit:
   
   git commit -m "my first website ready"
   

8. View commit history:
   
   git log
   
   or
   
   git log --oneline
   

9. `.gitignore`
   - Used to tell Git which files/folders should not be tracked.
   - Example: ignore files/folders that should not be pushed to the repository.

10. Git does **not track empty folders**.
   - To keep an otherwise empty folder in Git, create a placeholder such as:
   text
   .gitkeep
   
   - Then Git will track the folder through that file.

### GitHub

- GitHub is an online platform where repositories are hosted.
- A developer can push a local repository to GitHub.
- GitHub allows repositories/code to be shared and collaborated on.

### Important Flow

text
Working Directory
       ↓
   git add
       ↓
Staging Area
       ↓
 git commit
       ↓
Local Repository
       ↓
   git push
       ↓
Remote Repository / GitHub

Next »

No comments:

Post a Comment