Answer
Overview
GitHub is a web-based platform for hosting Git repositories, enabling collaboration, code review, CI/CD, and project management.
Common GitHub Interview Questions
1. Git Workflow (Branching Strategy)
bash# Feature branch workflow git checkout main git pull origin main git checkout -b feature/user-auth # Create feature branch # ... make changes ... git add . git commit -m "feat: add user authentication" git push origin feature/user-auth # Create Pull Request → Review → Merge
2. Pull Request (PR) Process
text1. Create feature branch from main 2. Make changes + commit 3. Push branch to GitHub 4. Open Pull Request (PR) on GitHub 5. Team reviews code → suggests changes 6. Address feedback → update PR 7. Approvals received → Merge to main 8. Delete feature branch
3. Git Rebase vs Merge
bash# Merge — preserves history, creates a merge commit git checkout main && git merge feature-branch # Result: non-linear history with merge commits # Rebase — replays commits on top, linear history git checkout feature-branch && git rebase main # Result: clean linear history, no merge commits
| Merge | Rebase | |
|---|---|---|
| History | Non-linear (merge commits) | Linear |
| Safety | Safe on shared branches | ⚠️ Don't rebase shared branches |
| Use when | Merging feature to main | Keeping branch up to date |
4. Git Commands Reference
bashgit init # Initialize repo git clone <url> # Clone remote repo git status # Show changes git add . # Stage all changes git commit -m "message" # Commit staged changes git push origin branch-name # Push to remote git pull origin main # Fetch + merge from remote git fetch # Fetch without merging git log --oneline # Short commit history git diff # Show unstaged changes git stash # Temporarily save changes git stash pop # Restore stashed changes git reset --soft HEAD~1 # Undo last commit (keep changes staged) git reset --hard HEAD~1 # Undo last commit (discard changes) git cherry-pick <commit-hash> # Apply specific commit to current branch
5. GitHub Actions (CI/CD)
yaml# .github/workflows/flutter.yml name: Flutter CI on: push: branches: [ main ] pull_request: branches: [ main ] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: subosito/flutter-action@v2 with: flutter-version: '3.x' - run: flutter pub get - run: flutter analyze - run: flutter test - run: flutter build apk --release
6. .gitignore for Flutter
gitignore# Flutter/Dart .dart_tool/ .flutter-plugins .flutter-plugins-dependencies build/ *.iml # Android android/.gradle android/local.properties android/key.properties # ← Never commit signing keys! # iOS ios/Pods/ ios/.symlinks/
Git Best Practices
| Practice | Why |
|---|---|
| Commit often with clear messages | Easy to review and revert |
| Use conventional commits ( text text text | Automated changelogs |
| Never commit secrets/keys | Security risk |
| Squash commits before merging | Clean history |
| Always branch from main/develop | Safe isolation |
| Code review all PRs | Catch bugs early |
Conventional Commits:
(new feature),textfeat:(bug fix),textfix:(maintenance),textchore:(documentation),textdocs:(code change),textrefactor:(tests)texttest: