54 lines
1.5 KiB
Markdown
54 lines
1.5 KiB
Markdown
# Git & Version Control Skill
|
|
|
|
## Git Configuration
|
|
```bash
|
|
git config --global user.name "ren"
|
|
git config --global user.email "ren@local"
|
|
git config --global init.defaultBranch main
|
|
```
|
|
|
|
## Common Commands
|
|
|
|
### Repository Operations
|
|
```bash
|
|
git init # Initialize repo
|
|
git clone <url> # Clone repo
|
|
git status # Check status
|
|
git add . # Stage all changes
|
|
git add file.js # Stage specific file
|
|
git commit -m "message" # Commit
|
|
git push origin main # Push to remote
|
|
git pull origin main # Pull from remote
|
|
```
|
|
|
|
### Branching
|
|
```bash
|
|
git branch # List branches
|
|
git branch new-feature # Create branch
|
|
git checkout new-feature # Switch branch
|
|
git checkout -b feature # Create and switch
|
|
git merge feature # Merge branch
|
|
git branch -d feature # Delete merged branch
|
|
```
|
|
|
|
### History & Diff
|
|
```bash
|
|
git log --oneline # Compact history
|
|
git diff # Show changes
|
|
git diff HEAD~1 # Compare with previous
|
|
git show <commit> # Show commit details
|
|
git reset --hard <commit> # Reset to commit
|
|
```
|
|
|
|
## Advanced
|
|
```bash
|
|
git stash # Stash changes
|
|
git stash pop # Apply stash
|
|
git cherry-pick <commit> # Pick specific commit
|
|
git rebase main # Rebase branch
|
|
```
|
|
|
|
## SSH Configuration
|
|
- SSH configured at: ~/.ssh/
|
|
- Public key can be added to GitHub/GitLab
|