1. git diff
Shows changes between working directory and index or between commits.
git diff
git diff --staged
git diff HEAD
2. git log
Displays commit history.
git log
git log --oneline
git log --graph
3. git clone
Clones a repository from remote (e.g., GitHub) to your system.
git clone
git clone https://github.com/username/project.git
4. git pull
Fetches and merges changes from the remote repository.
git pull origin main
5. git push
Pushes local commits to the remote repository.
git push origin main
6. git blame
Shows who made each line change and when.
git blame filename
7. .gitignore
Tells Git to ignore specific files/folders.
Create a .gitignore
file in the root of your repo and add patterns:
node_modules/
.env
*.log
/dist
8. git branch
Manages branches in your repo.
git branch
git branch new-feature
git checkout new-feature
9. Git Merge Conflict
Occurs when merging changes and Git can't automatically resolve differences.
Steps:
git checkout main
git pull
git merge feature-branch
git add .
git commit
10. Git Fork (on GitHub)
Forking creates a personal copy of someone else's repo.
Steps:
- Go to a repo on GitHub.
- Click Fork (top-right).
- Clone your fork:
git clone https://github.com/your-username/forked-repo.git
11. GitHub Wiki
Used for project documentation inside the GitHub repo.
How to Use:
- Go to your GitHub repository.
- Click on the "Wiki" tab.
- Click "Create the first page".
- Add pages/sections with Markdown like
.md
files.