- Published on
Git Workflow for Developers
- Authors

- Name
- Rakesh Tembhurne
- @tembhurnerakesh
Introduction
Version control is the backbone of modern software development. While most developers know basic Git commands, mastering advanced workflows, Git Flow, GitHub CLI, and GitLab CLI can dramatically improve productivity and collaboration.
This guide is organized by workflow topics rather than individual tools, allowing you to compare different approaches for each task. Each section covers the same workflow using Git, Git Flow, GitHub CLI, and GitLab CLI where applicable.
Who Is This Guide For?
This guide serves two primary audiences:
👨💻 Developers - Focus on code workflows including:
- Daily development operations (commit, branch, merge)
- Feature development and code review
- Debugging and troubleshooting
- Local repository management
📊 Project Managers - Focus on project management workflows including:
- Issue and milestone tracking
- Team coordination and sprint planning
- Release management and versioning
- Progress monitoring and reporting
Throughout this guide, workflows are marked with role indicators:
- [Developer] - Primarily for developers
- [PM] - Primarily for project managers
- [Both] - Relevant for both roles
Getting Started: Installation & Setup
Git Installation
# macOS
brew install git
# Ubuntu/Debian
sudo apt install git
# Windows
# Download from https://git-scm.com/download/win
# Verify installation
git --version
Git Flow Installation
# macOS
brew install git-flow-avh
# Ubuntu/Debian
apt-get install git-flow
# Windows (Git Bash)
wget -q -O - --no-check-certificate \
https://raw.github.com/petervanderdoes/gitflow-avh/develop/contrib/gitflow-installer.sh \
install stable | bash
GitHub CLI Installation
# macOS
brew install gh
# Ubuntu/Debian
sudo apt install gh
# Windows (via winget)
winget install --id GitHub.cli
# Verify installation
gh --version
GitLab CLI Installation
# macOS
brew install glab
# Ubuntu/Debian (via snap)
snap install glab
# Windows (via scoop)
scoop install glab
# Verify installation
glab version
Authentication & Configuration
Git Configuration
# Set user identity
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
# Set default editor
git config --global core.editor vim
# Set default branch name
git config --global init.defaultBranch main
# View configuration
git config --list
Git Flow Initialization
# Initialize in existing repository
git flow init
# Accept defaults or customize:
# - Production branch: main
# - Development branch: develop
# - Feature prefix: feature/
# - Release prefix: release/
# - Hotfix prefix: hotfix/
# - Version tag prefix: v
# Initialize with defaults (non-interactive)
git flow init -d
GitHub CLI Authentication
# Login to GitHub
gh auth login
# Choose: GitHub.com
# Choose: HTTPS or SSH
# Authenticate via web browser
# Check authentication status
gh auth status
# Login with token
gh auth login --with-token < token.txt
# Configure defaults
gh config set editor vim
gh config set git_protocol ssh
# Logout
gh auth logout
GitLab CLI Authentication
# Login to GitLab
glab auth login
# Choose: GitLab.com or self-hosted
# Enter token or authenticate via browser
# Login with token
glab auth login --token YOUR_TOKEN
# Login to self-hosted GitLab
glab auth login --hostname gitlab.company.com
# Check status
glab auth status
# Configuration
glab config set editor vim
glab config set git_protocol ssh
# Switch accounts
glab auth switch
Repository Management
Creating a Repository
Git (local only):
# Initialize new repository
git init
# Initialize with specific branch name
git init -b main
GitHub CLI:
# Create repository (interactive)
gh repo create my-project
# Create public repository
gh repo create my-project --public
# Create private repository
gh repo create my-project --private
# Create from template
gh repo create my-project --template owner/template-repo
# Create in organization
gh repo create org/my-project --internal
GitLab CLI:
# Create repository (interactive)
glab repo create my-project
# Create public repository
glab repo create my-project --public
# Create private repository
glab repo create my-project --private
# Create internal repository
glab repo create my-project --internal
Cloning a Repository
Git:
# Clone repository
git clone https://github.com/username/repo.git
# Clone specific branch
git clone -b branch-name https://github.com/username/repo.git
# Shallow clone (faster)
git clone --depth 1 https://github.com/username/repo.git
GitHub CLI:
# Clone by name
gh repo clone owner/repo
# Clone by URL
gh repo clone https://github.com/owner/repo
GitLab CLI:
# Clone by namespace/project
glab repo clone namespace/project
# Clone by ID
glab repo clone 123
Forking a Repository
Git (manual):
# Fork through web interface, then clone
git clone https://github.com/your-username/forked-repo.git
# Add upstream remote
git remote add upstream https://github.com/original-owner/repo.git
GitHub CLI:
# Fork and clone
gh repo fork owner/repo
# Fork only (no clone)
gh repo fork owner/repo --clone=false
GitLab CLI:
# Fork repository
glab repo fork namespace/project
# Fork and clone
glab repo fork namespace/project --clone
Viewing Repository Information
Git:
# View remotes
git remote -v
# View repository status
git status
# View commit history
git log --oneline --graph --all
GitHub CLI:
# View current repository
gh repo view
# View specific repository
gh repo view owner/repo
# Open in browser
gh repo view owner/repo --web
# List your repositories
gh repo list
gh repo list owner --limit 50
GitLab CLI:
# View current repository
glab repo view
# View specific repository
glab repo view namespace/project
# Open in browser
glab repo view namespace/project --web
# List repositories
glab repo list
glab repo list --member
Branch Management
Creating and Switching Branches
Git:
# List branches
git branch # Local branches
git branch -r # Remote branches
git branch -a # All branches
# Create branch
git branch feature-branch
# Switch to branch
git checkout feature-branch
git switch feature-branch # Modern way
# Create and switch
git checkout -b new-feature
git switch -c new-feature # Modern way
# Rename branch
git branch -m old-name new-name
git branch -m new-name # Rename current branch
Git Flow:
# Start new feature (creates and switches)
git flow feature start user-authentication
# Creates: feature/user-authentication from develop
# List features
git flow feature list
# Switch between features
git checkout feature/feature-name
# Publish feature to remote
git flow feature publish user-authentication
# Track remote feature
git flow feature track user-authentication
Deleting Branches
Git:
# Delete local branch (safe)
git branch -d feature-branch
# Force delete local branch
git branch -D feature-branch
# Delete remote branch
git push origin --delete feature-branch
Git Flow:
# Delete feature without merging
git flow feature delete user-authentication
# Finish feature (merges and deletes)
git flow feature finish user-authentication
GitHub CLI:
# Delete branch when closing PR
gh pr close 123 --delete-branch
# Delete branch when merging PR
gh pr merge 123 --delete-branch
GitLab CLI:
# Delete branch when merging MR
glab mr merge 123 --remove-source-branch
# Create MR with auto-delete enabled
glab mr create --remove-source-branch
Daily Development Workflow
Checking Status and Changes
Git:
# Check repository status
git status
# View unstaged changes
git diff
# View staged changes
git diff --staged
# View changes in specific file
git diff filename.txt
# View commit history
git log
git log --oneline
git log --graph --oneline --all
Staging and Committing Changes
Git:
# Stage files
git add filename.txt # Add specific file
git add . # Add all changes
git add *.js # Add all JS files
git add -p # Interactive staging
# Commit changes
git commit -m "feat: Add user authentication"
git commit -am "fix: Resolve login bug" # Add and commit tracked files
# Amend last commit
git commit --amend
git commit --amend --no-edit
Git Flow (same as Git for commits):
# Work on feature branch
git flow feature start new-feature
# Make changes and commit normally
git add .
git commit -m "feat: Add new functionality"
git commit -m "test: Add unit tests"
# When done, finish feature
git flow feature finish new-feature
Stashing Work in Progress
Git:
# Stash changes
git stash
git stash save "WIP: feature X"
git stash -u # Include untracked files
# List stashes
git stash list
# View stash contents
git stash show
git stash show -p stash@{1}
# Apply stash
git stash apply # Keep stash
git stash pop # Apply and remove
# Delete stash
git stash drop stash@{1}
git stash clear # Delete all
Feature Development Workflow
Starting a New Feature
Git:
# Create feature branch from develop
git checkout develop
git pull origin develop
git checkout -b feature/user-authentication
Git Flow:
# Ensure on develop and up to date
git checkout develop
git pull origin develop
# Start feature (creates branch and switches)
git flow feature start user-authentication
# Creates: feature/user-authentication
Working on Feature
Git:
# Make changes and commit
git add .
git commit -m "feat: Add login form"
git commit -m "feat: Add password validation"
# Push feature branch
git push -u origin feature/user-authentication
# Keep feature updated with develop
git checkout develop
git pull origin develop
git checkout feature/user-authentication
git merge develop
Git Flow:
# Make commits normally
git add .
git commit -m "feat: Add login form"
# Publish for collaboration
git flow feature publish user-authentication
# Pull updates from remote
git flow feature pull origin user-authentication
# Update from develop
git checkout develop
git pull origin develop
git checkout feature/user-authentication
git merge develop
Creating Pull/Merge Request
Git (manual):
# Push feature branch
git push -u origin feature/user-authentication
# Create PR/MR through web interface
GitHub CLI:
# Create PR (interactive)
gh pr create
# Create PR with details
gh pr create \
--title "feat: Add user authentication" \
--body "Implements user login and registration" \
--base develop \
--label enhancement \
--reviewer @team-lead
# Create draft PR
gh pr create --draft
# Open browser to create PR
gh pr create --web
GitLab CLI:
# Create MR (interactive)
glab mr create
# Create MR with details
glab mr create \
--title "feat: Add user authentication" \
--description "Implements user login and registration" \
--source-branch feature/user-authentication \
--target-branch develop \
--label enhancement \
--assignee @team-lead
# Create draft MR
glab mr create --draft
# Create with auto-delete source branch
glab mr create --remove-source-branch
Finishing Feature
Git:
# After PR approval, merge via web interface
# Then update local branches
git checkout develop
git pull origin develop
# Delete feature branch
git branch -d feature/user-authentication
git push origin --delete feature/user-authentication
Git Flow:
# Finish feature (merges into develop and deletes branch)
git flow feature finish user-authentication
# Merges feature/user-authentication into develop
# Deletes the feature branch
# Switches back to develop
# Push changes
git push origin develop
GitHub CLI:
# Merge PR
gh pr merge 123 --squash --delete-branch
# Or interactive merge
gh pr merge 123
# Update local repository
git checkout develop
git pull origin develop
GitLab CLI:
# Merge MR
glab mr merge 123 --squash --remove-source-branch
# Or interactive merge
glab mr merge 123
# Update local repository
git checkout develop
git pull origin develop
Code Review Workflow
Listing Pull/Merge Requests
GitHub CLI:
# List all open PRs
gh pr list
# List your PRs
gh pr list --author @me
# List PRs assigned to you
gh pr list --assignee @me
# Filter by label
gh pr list --label bug
# Check PR status
gh pr status
GitLab CLI:
# List all open MRs
glab mr list
# List your MRs
glab mr list --author @me
# List MRs assigned to you
glab mr list --assignee @me
# Filter by label
glab mr list --label bug
# Check MR status
glab mr status
Reviewing Pull/Merge Requests
Git:
# Fetch PR branch manually
git fetch origin pull/123/head:pr-123
git checkout pr-123
# Review changes
git diff develop...pr-123
git log develop..pr-123
GitHub CLI:
# Checkout PR
gh pr checkout 123
# View PR details
gh pr view 123
gh pr view 123 --comments
# View diff
gh pr diff 123
# Check CI/CD status
gh pr checks 123
# Add review
gh pr review 123 --approve
gh pr review 123 --request-changes -b "Please add tests"
gh pr review 123 --comment -b "Looks good!"
GitLab CLI:
# Checkout MR
glab mr checkout 123
# View MR details
glab mr view 123
glab mr view 123 --comments
# View diff
glab mr diff 123
# Approve MR
glab mr approve 123
# Add note/comment
glab mr note 123 -m "Please add tests"
# Revoke approval
glab mr revoke 123
Merging Pull/Merge Requests
GitHub CLI:
# Interactive merge
gh pr merge 123
# Merge with strategy
gh pr merge 123 --merge # Create merge commit
gh pr merge 123 --squash # Squash and merge
gh pr merge 123 --rebase # Rebase and merge
# Auto-delete branch
gh pr merge 123 --delete-branch
# Auto-merge when checks pass
gh pr merge 123 --auto
GitLab CLI:
# Interactive merge
glab mr merge 123
# Merge with strategy
glab mr merge 123 --squash
glab mr merge 123 --rebase
# Auto-delete branch
glab mr merge 123 --remove-source-branch
# Auto-merge when pipeline succeeds
glab mr merge 123 --when-pipeline-succeeds
Release Management
Creating a Release
Git:
# Create release branch
git checkout develop
git pull origin develop
git checkout -b release/1.0.0
# Update version files
echo "1.0.0" > VERSION
git commit -am "chore: Bump version to 1.0.0"
# Merge to main
git checkout main
git merge --no-ff release/1.0.0
# Tag release
git tag -a v1.0.0 -m "Release version 1.0.0"
# Merge back to develop
git checkout develop
git merge --no-ff release/1.0.0
# Push everything
git push origin main develop --tags
# Delete release branch
git branch -d release/1.0.0
Git Flow:
# Start release from develop
git flow release start 1.0.0
# Creates: release/1.0.0 from develop
# Update version files
echo "1.0.0" > VERSION
git commit -am "chore: Bump version to 1.0.0"
# Publish for team review
git flow release publish 1.0.0
# Finish release
git flow release finish 1.0.0
# Merges to main
# Creates tag v1.0.0
# Merges back to develop
# Deletes release branch
# Push everything
git push origin main develop --tags
GitHub CLI:
# After git flow release finish or manual merge/tag
# Create GitHub release
gh release create v1.0.0 \
--title "Version 1.0.0" \
--notes "Release notes here" \
dist/*.zip
# Auto-generate release notes
gh release create v1.0.0 --generate-notes
# Create draft release
gh release create v1.0.0 --draft
# Create pre-release
gh release create v1.0.0 --prerelease
GitLab CLI:
# After git flow release finish or manual merge/tag
# Create GitLab release
glab release create v1.0.0 \
--name "Version 1.0.0" \
--notes "Release notes here" \
dist/*.zip
# Create from specific ref
glab release create v1.0.0 --ref main
# Use notes from file
glab release create v1.0.0 --notes-file CHANGELOG.md
Listing and Viewing Releases
Git:
# List tags
git tag
git tag -l "v1.*"
# View tag details
git show v1.0.0
# Checkout specific version
git checkout v1.0.0
GitHub CLI:
# List releases
gh release list
gh release list --limit 10
# View release
gh release view v1.0.0
# Open in browser
gh release view v1.0.0 --web
# Download release assets
gh release download v1.0.0
gh release download v1.0.0 -p "*.zip"
GitLab CLI:
# List releases
glab release list
glab release list --tag v*
# View release
glab release view v1.0.0
# Open in browser
glab release view v1.0.0 --web
# Download release assets
glab release download v1.0.0
glab release download v1.0.0 --asset-name app.zip
Updating and Deleting Releases
Git:
# Update tag (not recommended)
git tag -f -a v1.0.0 -m "Updated release notes"
git push -f origin v1.0.0
# Delete tag
git tag -d v1.0.0
git push origin --delete v1.0.0
GitHub CLI:
# Edit release
gh release edit v1.0.0 --title "New title"
gh release edit v1.0.0 --notes "Updated notes"
# Upload additional assets
gh release upload v1.0.0 dist/*.zip
# Delete release
gh release delete v1.0.0
gh release delete v1.0.0 --yes # Skip confirmation
GitLab CLI:
# Update release
glab release update v1.0.0 --name "New name"
glab release update v1.0.0 --notes "Updated notes"
# Upload assets
glab release upload v1.0.0 dist/*.zip
# Delete release
glab release delete v1.0.0
Hotfix Workflow
Creating a Hotfix
Git:
# Create hotfix branch from main
git checkout main
git pull origin main
git checkout -b hotfix/security-patch-1.0.1
# Fix the bug
git add .
git commit -m "fix: Patch XSS vulnerability"
# Merge to main
git checkout main
git merge --no-ff hotfix/security-patch-1.0.1
git tag -a v1.0.1 -m "Security patch 1.0.1"
# Merge to develop
git checkout develop
git merge --no-ff hotfix/security-patch-1.0.1
# Push everything
git push origin main develop --tags
# Delete hotfix branch
git branch -d hotfix/security-patch-1.0.1
Git Flow:
# Start hotfix from main
git flow hotfix start security-patch-1.0.1
# Creates: hotfix/security-patch-1.0.1 from main
# Fix the bug
git add .
git commit -m "fix: Patch XSS vulnerability"
# Finish hotfix
git flow hotfix finish security-patch-1.0.1
# Merges to main
# Creates tag
# Merges to develop
# Deletes hotfix branch
# Push everything
git push origin main develop --tags
GitHub CLI:
# After pushing hotfix branch
gh pr create \
--title "fix: Critical security patch" \
--body "Patches XSS vulnerability" \
--base main \
--label security,hotfix
# After approval, merge
gh pr merge --squash --delete-branch
# Create release
gh release create v1.0.1 --notes "Security patch"
GitLab CLI:
# After pushing hotfix branch
glab mr create \
--title "fix: Critical security patch" \
--description "Patches XSS vulnerability" \
--target-branch main \
--label security,hotfix
# After approval, merge
glab mr merge --squash --remove-source-branch
# Create release
glab release create v1.0.1 --notes "Security patch"
Tag Management
Creating Tags
Git:
# Lightweight tag
git tag v1.0.0
# Annotated tag (recommended)
git tag -a v1.0.0 -m "Release version 1.0.0"
# Tag specific commit
git tag -a v1.0.0 abc123 -m "Release 1.0.0"
# Push tags
git push origin v1.0.0 # Push specific tag
git push origin --tags # Push all tags
Git Flow:
# Tags are created automatically when finishing releases/hotfixes
git flow release finish 1.0.0
# Creates tag: v1.0.0 (prefix configurable)
git flow hotfix finish 1.0.1
# Creates tag: v1.0.1
# Custom tag message
git flow release finish -m "Release version 1.0.0" 1.0.0
GitHub CLI:
# Create release (creates tag automatically)
gh release create v1.0.0 --title "Version 1.0.0"
# Tags are managed through releases
# Use git commands for manual tagging
GitLab CLI:
# Create release (creates tag automatically)
glab release create v1.0.0 --name "Version 1.0.0"
# Tags are managed through releases
# Use git commands for manual tagging
Listing and Viewing Tags
Git:
# List all tags
git tag
# List with pattern
git tag -l "v1.*"
# Show tag details
git show v1.0.0
# Checkout tag
git checkout v1.0.0
GitHub CLI:
# List releases (which include tags)
gh release list
# View release
gh release view v1.0.0
GitLab CLI:
# List releases (which include tags)
glab release list
# View release
glab release view v1.0.0
Deleting Tags
Git:
# Delete local tag
git tag -d v1.0.0
# Delete remote tag
git push origin --delete v1.0.0
# Delete tag and recreate
git tag -d v1.0.0
git push origin --delete v1.0.0
git tag -a v1.0.0 -m "Updated tag"
git push origin v1.0.0
GitHub CLI:
# Delete release (keeps tag)
gh release delete v1.0.0
# To delete tag, use git commands
git push origin --delete v1.0.0
GitLab CLI:
# Delete release (keeps tag)
glab release delete v1.0.0
# To delete tag, use git commands
git push origin --delete v1.0.0
Issue Management
Creating Issues
GitHub CLI:
# Create issue (interactive)
gh issue create
# Create with details
gh issue create \
--title "Bug in login form" \
--body "Description of the bug" \
--label bug,urgent \
--assignee @me \
--milestone v1.0
# Create from template
gh issue create --template bug_report.md
GitLab CLI:
# Create issue (interactive)
glab issue create
# Create with details
glab issue create \
--title "Bug in login form" \
--description "Description of the bug" \
--label bug,urgent \
--assignee @me \
--milestone v1.0
# Create confidential issue
glab issue create --confidential
Managing Issues
GitHub CLI:
# List issues
gh issue list
gh issue list --state closed
gh issue list --assignee @me
gh issue list --label bug
# View issue
gh issue view 42
gh issue view 42 --web
gh issue view 42 --comments
# Edit issue
gh issue edit 42 --title "New title"
gh issue edit 42 --add-label enhancement
gh issue edit 42 --add-assignee @username
# Close/Reopen
gh issue close 42
gh issue close 42 --reason "not planned"
gh issue reopen 42
# Comment
gh issue comment 42 -b "This is a comment"
# Pin issue
gh issue pin 42
GitLab CLI:
# List issues
glab issue list
glab issue list --state closed
glab issue list --assignee @me
glab issue list --label bug
# View issue
glab issue view 42
glab issue view 42 --web
glab issue view 42 --comments
# Update issue
glab issue update 42 --title "New title"
glab issue update 42 --label enhancement
glab issue update 42 --assignee @username
# Close/Reopen
glab issue close 42
glab issue close 42 -m "Fixed in !123"
glab issue reopen 42
# Add note
glab issue note 42 -m "This is a comment"
# Link issues
glab issue link 42 43
CI/CD Pipeline Management
Viewing Workflow/Pipeline Status
Git:
# No built-in CI/CD commands
# View status through web interface or CI/CD provider CLI
GitHub CLI:
# List workflows
gh workflow list
# View workflow
gh workflow view ci.yml
# List workflow runs
gh run list
gh run list --workflow=ci.yml
gh run list --branch=main
gh run list --status=failure
# View run
gh run view 123456
gh run view --log
# Watch run (live)
gh run watch 123456
# Check PR checks
gh pr checks
gh pr checks 123
GitLab CLI:
# List pipelines
glab pipeline list
glab pipeline list --status failed
glab pipeline list --branch main
# View pipeline
glab pipeline view 12345
glab pipeline view --jobs
# Pipeline status
glab pipeline status
glab pipeline status --branch main
# List jobs
glab job list
glab job view 67890
glab job logs 67890
glab job trace 67890 # Follow logs
Triggering Workflows/Pipelines
GitHub CLI:
# Run workflow
gh workflow run ci.yml
# Run with inputs
gh workflow run ci.yml -f environment=production
# Re-run workflow
gh run rerun 123456
gh run rerun 123456 --failed # Only failed jobs
# Cancel run
gh run cancel 123456
GitLab CLI:
# Trigger pipeline
glab pipeline run
glab pipeline run --branch develop
# Trigger with variables
glab pipeline run --variable KEY=value
# Retry pipeline
glab pipeline retry 12345
# Cancel pipeline
glab pipeline cancel 12345
# Trigger manual job
glab job play 67890
Downloading Artifacts
GitHub CLI:
# Download all artifacts
gh run download 123456
# Download specific artifact
gh run download 123456 -n artifact-name
# Download from specific run
gh run download --repo owner/repo 123456
GitLab CLI:
# Download job artifacts
glab job download 67890
# Artifacts are downloaded from specific jobs
Advanced Git Operations
Merging and Rebasing
Git:
# Merge branch
git merge feature-branch # Fast-forward if possible
git merge --no-ff feature-branch # Always create merge commit
git merge --squash feature-branch # Squash all commits
# Rebase branch
git rebase main # Rebase current branch onto main
git rebase -i HEAD~3 # Interactive rebase last 3 commits
git rebase --continue # Continue after resolving conflicts
git rebase --abort # Cancel rebase
Cherry-picking Commits
Git:
# Cherry-pick single commit
git cherry-pick abc123
# Cherry-pick multiple commits
git cherry-pick abc123 def456
# Cherry-pick without committing
git cherry-pick --no-commit abc123
# Continue after conflicts
git cherry-pick --continue
Undoing Changes
Git:
# Unstage files
git reset HEAD filename.txt
git restore --staged filename.txt # Modern way
# Discard changes
git checkout -- filename.txt
git restore filename.txt # Modern way
# Reset commits (local only)
git reset --soft HEAD~1 # Keep changes staged
git reset --mixed HEAD~1 # Keep changes unstaged
git reset --hard HEAD~1 # Discard all changes
# Revert commits (creates new commit)
git revert abc123
git revert HEAD
git revert --no-commit HEAD~3..HEAD
# Clean untracked files
git clean -fd # Remove files and directories
git clean -fdn # Dry run
Searching and Debugging
Git:
# Search commit messages
git log --grep="bug fix"
git log --author="John Doe"
git log --since="2 weeks ago"
# Search code changes
git log -S "function_name" # Pickaxe search
git log -G "regex_pattern" # Regex search
# Blame (who changed what)
git blame filename.txt
git blame -L 10,20 filename.txt # Specific lines
# Find bugs with bisect
git bisect start
git bisect bad # Current commit is bad
git bisect good v1.0.0 # Known good commit
# Git checks out commits to test
git bisect good # Mark as good
git bisect bad # Mark as bad
git bisect reset # End session
Project Management
Managing Labels
GitHub CLI:
# List labels
gh label list
# Create label
gh label create bug --color E11D48 --description "Bug reports"
# Edit label
gh label edit bug --color FF0000 --name critical-bug
# Delete label
gh label delete bug
GitLab CLI:
# List labels
glab label list
# Create label
glab label create bug --color "#FF0000"
# Update label
glab label update bug --new-name critical-bug
# Delete label
glab label delete bug
Managing Milestones
GitHub CLI:
# List milestones
gh milestone list
# Create milestone
gh milestone create v1.0 --due-date 2025-12-31 --description "Release 1.0"
# Edit milestone
gh milestone edit v1.0 --title "Version 1.0 Release"
# Using API for more control
gh api repos/:owner/:repo/milestones -f title='Sprint 23'
GitLab CLI:
# List milestones
glab milestone list
# Create milestone
glab milestone create v1.0 --due-date 2025-12-31 --description "Release 1.0"
# View milestone
glab milestone view v1.0
# Update milestone
glab milestone update v1.0 --title "Version 1.0 Release"
# Close milestone
glab milestone close v1.0
Searching
GitHub CLI:
# Search repositories
gh search repos "react hooks"
gh search repos --language=javascript --stars=">=1000"
# Search issues
gh search issues "bug"
gh search issues "is:open is:issue label:bug author:@me"
# Search pull requests
gh search prs "state:open"
GitLab CLI:
# Search across GitLab
glab search issues "bug"
glab search mrs "feature"
glab search projects "web app"
# Project search
glab project search "query"
Aliases and Productivity
Git Aliases
Git:
# Set aliases in git config
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.st status
git config --global alias.unstage 'reset HEAD --'
git config --global alias.last 'log -1 HEAD'
git config --global alias.visual 'log --oneline --graph --all'
# Use aliases
git co main
git visual
GitHub CLI Aliases
GitHub CLI:
# Create aliases
gh alias set co 'pr checkout'
gh alias set pv 'pr view'
gh alias set bugs 'issue list --label=bug'
gh alias set prs 'pr list --author @me'
# List aliases
gh alias list
# Delete alias
gh alias delete co
# Use aliases
gh co 123
gh bugs
GitLab CLI Aliases
GitLab CLI:
# Create aliases
glab alias set co 'mr checkout'
glab alias set mv 'mr view'
glab alias set bugs 'issue list --label=bug'
glab alias set myMRs 'mr list --author @me'
# List aliases
glab alias list
# Delete alias
glab alias delete co
# Use aliases
glab co 123
glab bugs
Comparison: Tools Overview
| Feature | Git | Git Flow | GitHub CLI | GitLab CLI |
|---|---|---|---|---|
| Branch Management | Manual | Structured workflow | Not applicable | Not applicable |
| Pull/Merge Requests | Web only | Web only | gh pr | glab mr |
| Issues | Not supported | Not supported | gh issue | glab issue |
| Releases | Tags only | Tags via finish | gh release | glab release |
| CI/CD | Not supported | Not supported | gh workflow/run | glab pipeline/job |
| Code Review | Manual | Manual | gh pr review | glab mr approve |
| Best For | Core operations | Team workflows | GitHub integration | GitLab integration |
Real-World Workflow Examples
Complete Feature Development Flow
# 1. Start feature (Git Flow)
git checkout develop && git pull
git flow feature start user-dashboard
# 2. Develop and commit
git add .
git commit -m "feat: Add dashboard layout"
git commit -m "feat: Add data fetching"
git commit -m "test: Add dashboard tests"
# 3. Push and create PR (GitHub)
git push -u origin feature/user-dashboard
gh pr create --title "feat: User Dashboard" --base develop --draft
# 4. Ready for review
gh pr ready 123
gh pr edit 123 --add-reviewer @team-lead,@designer
# 5. Address review comments
git add .
git commit -m "fix: Address review comments"
git push
# 6. Merge after approval
gh pr merge 123 --squash --delete-branch
# 7. Finish feature locally
git checkout develop && git pull
git flow feature finish user-dashboard
Hotfix Emergency Flow
# 1. Start hotfix (Git Flow)
git flow hotfix start critical-fix-1.0.1
# 2. Fix and test
git add .
git commit -m "fix: Critical security vulnerability"
# 3. Push and create urgent PR
git push -u origin hotfix/critical-fix-1.0.1
gh pr create --title "URGENT: Security patch" \
--base main --label security,urgent
# 4. Fast-track review and merge
gh pr merge --admin --squash
# 5. Finish hotfix (merges to main and develop)
git flow hotfix finish critical-fix-1.0.1
# 6. Create immediate release
gh release create v1.0.1 \
--title "Security Patch 1.0.1" \
--notes "Critical security fix"
# 7. Push all changes
git push origin main develop --tags
Release Preparation Flow
# 1. Start release (Git Flow)
git checkout develop && git pull
git flow release start 2.0.0
# 2. Prepare release
echo "2.0.0" > VERSION
npm version 2.0.0
git commit -am "chore: Bump version to 2.0.0"
# 3. Update changelog
gh pr list --state merged --search "milestone:v2.0" --json number,title
# Update CHANGELOG.md
git commit -am "docs: Update CHANGELOG for 2.0.0"
# 4. Final testing
npm test
npm run build
# 5. Finish release (Git Flow)
git flow release finish -m "Release 2.0.0" 2.0.0
# 6. Push everything
git push origin main develop --tags
# 7. Create GitHub release
gh release create v2.0.0 \
--title "Version 2.0.0" \
--notes-file CHANGELOG.md \
--verify-tag \
dist/*.zip
Team Code Review Flow
# REVIEWER WORKFLOW
# 1. List assigned PRs
gh pr list --assignee @me
# 2. Checkout and test
gh pr checkout 456
npm install
npm test
npm run dev # Manual testing
# 3. Review code
gh pr diff 456
gh pr view 456 --comments
# 4. Request changes or approve
gh pr review 456 --request-changes -b "Please add error handling"
# OR
gh pr review 456 --approve -b "LGTM! Great work"
# 5. After changes, re-review
git pull
npm test
gh pr review 456 --approve
# AUTHOR WORKFLOW (addressing feedback)
# 1. View feedback
gh pr view 456 --comments
# 2. Make changes
git add .
git commit -m "fix: Add error handling"
git push
# 3. Reply to comments
gh pr comment 456 -b "Added error handling as requested"
Sprint Planning Flow (Project Manager)
# 1. Create milestone
gh api repos/:owner/:repo/milestones \
-f title='Sprint 23' \
-f due_on='2025-10-31T00:00:00Z' \
-f description='Q4 2025 Sprint 23'
# 2. Create sprint issues
gh issue create -t "Implement user dashboard" \
-b "Design and implement user dashboard" \
-l feature,frontend -m "Sprint 23"
gh issue create -t "Add API rate limiting" \
-b "Implement rate limiting on API endpoints" \
-l enhancement,backend -m "Sprint 23"
gh issue create -t "Fix login timeout bug" \
-b "Users getting logged out unexpectedly" \
-l bug,priority:high -m "Sprint 23"
# 3. Assign issues
gh issue edit 101 --add-assignee @frontend-dev
gh issue edit 102 --add-assignee @backend-dev
gh issue edit 103 --add-assignee @backend-dev
# 4. Track sprint progress
gh issue list --milestone "Sprint 23"
gh pr list --search "milestone:Sprint-23"
# 5. Generate sprint report
gh issue list --milestone "Sprint 23" --state all --json number,title,state
Best Practices
Git Best Practices
- Commit early, commit often - Small, atomic commits are easier to review and revert
- Write meaningful commit messages - Follow conventional commit format
- Keep commits focused - One logical change per commit
- Pull before push - Always sync with remote before pushing
- Use branches - Never work directly on main/develop
- Review before committing - Use
git diffto review changes
Git Flow Best Practices
- Start from develop - All features should branch from develop
- Keep features small - Merge frequently to avoid conflicts
- Use meaningful names -
feature/user-authnotfeature/stuff - Publish for collaboration - Use
git flow feature publishfor team features - Hotfixes only for emergencies - Use features for non-critical fixes
- Tag all releases - Use semantic versioning (v1.0.0, v1.0.1, v2.0.0)
CLI Tools Best Practices
- Create aliases - Save time with frequently used commands
- Use templates - Standardize PR/issue descriptions
- Enable auto-merge - For approved PRs with passing checks
- Leverage CLI for automation - Script repetitive tasks
- Use draft PRs - Mark work-in-progress clearly
- Add context - Use labels, milestones, and assignees
Team Collaboration Best Practices
- Protect branches - Require reviews for main/develop
- Require status checks - Don't merge failing builds
- Use CI/CD - Automate testing and deployment
- Document workflows - Keep README and CONTRIBUTING.md updated
- Code review checklist - Consistent review standards
- Maintain changelog - Document changes for each release
Troubleshooting Common Issues
Merge Conflicts
# When conflicts occur during merge
git merge feature-branch
# CONFLICT message appears
# 1. View conflicted files
git status
# 2. Open and resolve conflicts in editor
# Look for <<<<<<< HEAD markers
# 3. Stage resolved files
git add resolved-file.txt
# 4. Complete merge
git commit
# Or abort merge
git merge --abort
Accidentally Committed to Wrong Branch
# Undo last commit but keep changes
git reset --soft HEAD~1
# Switch to correct branch
git checkout correct-branch
# Commit changes
git add .
git commit -m "feat: Correct commit"
Pushed Sensitive Data
# Remove from last commit
git rm --cached sensitive-file.txt
git commit --amend --no-edit
git push --force-with-lease
# For older commits, use git filter-branch or BFG Repo-Cleaner
# Then rotate all exposed credentials
Lost Commits
# View all commits including deleted ones
git reflog
# Recover lost commit
git checkout abc123
git checkout -b recovery-branch
Role-Specific Workflows
For Developers 👨💻
Daily Workflow:
# 1. Start your day - update local branches
git checkout develop
git pull origin develop
# 2. Create feature branch
git flow feature start user-profile-page
# 3. Code and commit regularly
git add .
git commit -m "feat: Add profile component"
git commit -m "feat: Add profile API integration"
git commit -m "test: Add profile tests"
# 4. Push and create PR
git push -u origin feature/user-profile-page
gh pr create --draft --title "feat: User Profile Page"
# 5. Mark ready for review
gh pr ready
gh pr edit --add-reviewer @team-lead
# 6. Address feedback
git add .
git commit -m "fix: Address review comments"
git push
# 7. After merge, clean up
git checkout develop && git pull
git branch -d feature/user-profile-page
Code Review Workflow:
# Check out colleague's PR
gh pr checkout 456
# Run tests locally
npm install
npm test
npm run build
# Review changes
gh pr diff 456
gh pr view 456 --comments
# Leave review
gh pr review 456 --comment -b "Looking good, few minor suggestions"
# Or approve
gh pr review 456 --approve -b "LGTM!"
Debugging Workflow:
# Find when bug was introduced
git bisect start
git bisect bad HEAD
git bisect good v1.5.0
# Test each commit
git bisect good/bad
git bisect reset
# Find who changed code
git blame src/components/Header.tsx -L 45,60
# Search for specific changes
git log -S "getUserProfile" --oneline
git log --grep="profile" --since="1 week ago"
# View file history
git log -p src/components/Profile.tsx
Emergency Hotfix:
# Quick fix for production bug
git flow hotfix start fix-login-bug-1.2.1
git add .
git commit -m "fix: Resolve login timeout issue"
git flow hotfix finish fix-login-bug-1.2.1
git push origin main develop --tags
gh release create v1.2.1 --notes "Hotfix: Login timeout resolved"
For Project Managers 📊
Sprint Planning Workflow:
# Create milestone for sprint
gh api repos/:owner/:repo/milestones \
-f title='Sprint 24 - Q4 2025' \
-f due_on='2025-11-15T00:00:00Z' \
-f description='Focus: User dashboard and API improvements'
# Bulk create issues from backlog
gh issue create -t "Design user dashboard mockups" \
-b "Create high-fidelity designs for dashboard" \
-l design,feature -m "Sprint 24" -a @designer
gh issue create -t "Implement dashboard backend API" \
-b "REST API endpoints for dashboard data" \
-l backend,api -m "Sprint 24" -a @backend-dev
gh issue create -t "Build dashboard frontend components" \
-b "React components for dashboard UI" \
-l frontend,react -m "Sprint 24" -a @frontend-dev
gh issue create -t "Dashboard integration testing" \
-b "End-to-end testing for dashboard" \
-l testing,qa -m "Sprint 24" -a @qa-engineer
# Label management
gh label create "priority:high" --color FF0000
gh label create "priority:medium" --color FFA500
gh label create "priority:low" --color 0000FF
Daily Standup Preparation:
# Check team's PR status
gh pr list --author @developer1 --json number,title,state,reviews
gh pr list --author @developer2 --json number,title,state,reviews
# Check sprint progress
gh issue list --milestone "Sprint 24" --json number,title,assignee,state
# Check CI/CD status
gh run list --branch develop --limit 5 --json status,conclusion,name
# Generate daily report
echo "Sprint 24 Daily Report - $(date +%Y-%m-%d)" > daily-report.md
echo "\n## Issues Status" >> daily-report.md
gh issue list --milestone "Sprint 24" --json number,title,state,assignee \
| jq -r '.[] | "- #\(.number): \(.title) (\(.state)) - @\(.assignee.login)"' \
>> daily-report.md
Release Management:
# 1. Check all merged PRs for release
gh pr list --state merged --search "milestone:v2.0" --json number,title,author
# 2. Generate release notes
gh pr list --state merged --search "milestone:v2.0" --json number,title,labels \
> release-prs.json
# 3. Start release process
git checkout develop && git pull
git flow release start 2.0.0
# 4. Update version and changelog
echo "2.0.0" > VERSION
# Update CHANGELOG.md with features, fixes, breaking changes
# 5. Final approval and release
git flow release finish 2.0.0
git push origin main develop --tags
# 6. Create GitHub release with notes
gh release create v2.0.0 \
--title "Version 2.0.0 - Dashboard Redesign" \
--notes-file CHANGELOG.md \
--verify-tag
# 7. Notify team
# Post in Slack/Teams about release
Sprint Retrospective & Reporting:
# Velocity calculation
echo "Sprint 24 Metrics" > sprint-24-metrics.md
echo "\n## Completed Issues" >> sprint-24-metrics.md
gh issue list --milestone "Sprint 24" --state closed --json number,title,closedAt \
| jq -r '.[] | "- #\(.number): \(.title)"' >> sprint-24-metrics.md
echo "\n## Incomplete Issues" >> sprint-24-metrics.md
gh issue list --milestone "Sprint 24" --state open --json number,title \
| jq -r '.[] | "- #\(.number): \(.title)"' >> sprint-24-metrics.md
echo "\n## PR Statistics" >> sprint-24-metrics.md
gh pr list --search "milestone:Sprint-24" --state all --json number,title,author,reviews
# Check code review metrics
gh pr list --search "milestone:Sprint-24 is:merged" --json number,reviews \
| jq '[.[] | .reviews | length] | add / length' # Average reviews per PR
Issue Triage Workflow:
# View new issues
gh issue list --state open --label "needs-triage"
# Categorize and prioritize
gh issue edit 123 --add-label bug,priority:high --milestone "Sprint 24"
gh issue edit 124 --add-label enhancement,priority:medium
gh issue edit 125 --add-label question --remove-label needs-triage
# Assign to team members based on expertise
gh issue edit 123 --add-assignee @backend-specialist
gh issue edit 124 --add-assignee @frontend-lead
# Close duplicates or invalid issues
gh issue close 126 --reason "duplicate"
gh issue comment 126 -b "Duplicate of #120"
Team Performance Monitoring:
# Check individual contributor stats (GitLab)
glab mr list --author @developer1 --state merged --created-after "1 week ago"
glab mr list --author @developer2 --state merged --created-after "1 week ago"
# Monitor pipeline success rate
glab pipeline list --status failed --created-after "1 week ago"
glab pipeline list --status success --created-after "1 week ago"
# Check review response times
gh pr list --state all --json number,createdAt,reviews \
| jq '.[] | {pr: .number, created: .createdAt, first_review: .reviews[0].submittedAt}'
# List blocked PRs
gh pr list --label "blocked" --json number,title,author
Milestone & Roadmap Management:
# Create quarterly milestones
gh api repos/:owner/:repo/milestones -f title='Q4 2025 - Phase 1'
gh api repos/:owner/:repo/milestones -f title='Q4 2025 - Phase 2'
gh api repos/:owner/:repo/milestones -f title='Q1 2026'
# Track milestone progress
gh issue list --milestone "Q4 2025 - Phase 1" --json state \
| jq 'group_by(.state) | map({state: .[0].state, count: length})'
# Update milestone due dates
gh api repos/:owner/:repo/milestones/123 \
-X PATCH -f due_on='2025-12-31T00:00:00Z'
# Generate roadmap report
for milestone in "Q4 2025 - Phase 1" "Q4 2025 - Phase 2" "Q1 2026"; do
echo "\n## $milestone"
gh issue list --milestone "$milestone" --json number,title,state
done > roadmap-report.md
Collaboration Between Roles
Developer-PM Sync Points:
Sprint Planning (PM leads, Developers participate)
- PM creates milestone and issues
- Developers estimate effort and flag technical concerns
- Both agree on sprint scope
Daily Updates (Both)
- Developers update PR/issue status
- PM monitors blockers and adjusts priorities
Code Review (Developer leads, PM monitors)
- Developers review code quality
- PM ensures PRs align with requirements
Release (Both collaborate)
- Developers prepare release branch and testing
- PM manages release notes and stakeholder communication
Shared Commands:
# Check sprint status (both roles)
gh issue list --milestone "Sprint 24"
gh pr list --search "milestone:Sprint-24"
# View project board (both roles)
gh project list
gh project view 1
# Check team availability (both roles)
gh pr list --assignee @developer1
gh issue list --assignee @developer1
# Release verification (both roles)
gh release view v2.0.0
git tag -l "v2.*"
Conclusion
This comprehensive guide covered Git workflows organized by task and role, making it easier to find exactly what you need regardless of whether you're a developer writing code or a project manager coordinating teams.
Key Takeaways:
For Developers:
- Master daily Git operations for efficient coding
- Use Git Flow for structured feature development
- Leverage CLI tools for faster PR reviews and merging
- Adopt debugging techniques like bisect and blame
- Automate repetitive tasks with aliases
For Project Managers:
- Use CLI tools for sprint planning and issue management
- Automate reporting and metrics generation
- Monitor team progress and blockers programmatically
- Manage releases and milestones efficiently
- Track team performance with data-driven insights
For Teams:
- Git provides the foundation for all version control operations
- Git Flow standardizes branching for team collaboration
- GitHub CLI brings GitHub workflows to the terminal
- GitLab CLI does the same for GitLab
- Clear role separation improves workflow efficiency
Next Steps by Role:
👨💻 Developers:
- Install Git, Git Flow, and your platform's CLI tool
- Set up aliases for frequently used commands
- Practice feature workflow on a test repository
- Master debugging commands (bisect, blame, log)
- Integrate CLI tools into your code editor
📊 Project Managers:
- Install GitHub CLI or GitLab CLI
- Set up authentication and API access
- Create templates for issues and PRs
- Build reporting scripts for your sprints
- Automate milestone and label management
Both Roles:
- Document your team's workflow in CONTRIBUTING.md
- Establish shared conventions (commit messages, PR titles)
- Use automation to reduce manual coordination
- Review and refine workflows regularly
- Foster collaboration through clear communication
The more you use these tools, the more natural they become. Developers can focus on code quality, project managers can focus on delivery, and together you create efficient, well-coordinated teams. Happy coding and managing!
Related Posts
Docker Swarm: Complete Deployment Guide for NestJS & Next.js Apps
Complete guide to deploying NestJS 11 backend and Next.js 15 frontend using Docker Swarm - single stack file for both dev and production, explicit 3-server setup with step-by-step commands.
Docker Complete Guide for Developers: Modern Practices for 2025
A comprehensive modern guide covering latest Docker features including BuildKit, Compose Watch, Docker Scout, Kubernetes deployment, and production-ready examples with PostgreSQL 17, Redis 7.4, Kafka 3.8, and ClickHouse.