0% found this document useful (0 votes)
12 views3 pages

Git Flow Guide

The document provides a comprehensive guide on Git flow, covering basic commands, branching strategies, and workflows for feature development, hotfixes, and releases. It explains the differences between merging and rebasing, as well as methods for cleaning up branches and undoing mistakes. Additionally, it touches on advanced tools like .gitignore and git stash for better version control management.

Uploaded by

The morning Star
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views3 pages

Git Flow Guide

The document provides a comprehensive guide on Git flow, covering basic commands, branching strategies, and workflows for feature development, hotfixes, and releases. It explains the differences between merging and rebasing, as well as methods for cleaning up branches and undoing mistakes. Additionally, it touches on advanced tools like .gitignore and git stash for better version control management.

Uploaded by

The morning Star
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Complete Git Flow Guide

1. Git Basics

git init # Initialize a Git repository


git clone <repo-url> # Clone a repository
git status # Show the working directory status
git add <file> # Stage a file
git commit -m "msg" # Commit staged changes
git push # Push changes to remote
git pull # Pull latest changes from remote

2. Branching Strategy

- main/master: Production-ready code


- develop: Integration branch (optional)
- feature/*: New features
- bugfix/*: Minor fixes
- hotfix/*: Critical fixes in production
- release/*: Release preparation

3. Git Workflow

1. Clone the Repository


git clone git@repo-url
cd repo

2. Create a Feature Branch


git checkout -b feature/your-feature-name

3. Work & Commit Frequently


git add .
git commit -m "Describe what you did"

4. Sync with Remote Develop/Main


git fetch origin
git rebase origin/main

5. Push Your Branch


git push origin feature/your-feature-name

6. Create a Pull Request (PR)


Use GitHub/GitLab UI

7. After PR Approval
git checkout main
git pull origin main
Complete Git Flow Guide

git merge feature/your-feature-name


git push origin main

8. Clean Up
git branch -d feature/your-feature-name
git push origin --delete feature/your-feature-name

4. Hotfix Flow

git checkout -b hotfix/critical-fix main


# Make fixes
git commit -am "Quick production fix"
git checkout main
git merge hotfix/critical-fix
git push origin main

5. Release Flow

git checkout -b release/v1.2.0 develop


# Final testing, version bump, etc.
git checkout main
git merge release/v1.2.0
git tag v1.2.0
git push origin main --tags

6. Git Rebase vs Merge

merge: Preserves commit history.


rebase: Cleaner linear history.

git checkout feature/xyz


git fetch origin
git rebase origin/main

7. Cleaning Up

git branch -d old-feature


git remote prune origin

8. Undoing Mistakes

Unstage: git reset HEAD <file>


Complete Git Flow Guide

Amend: git commit --amend


Log: git log --oneline --graph

9. Git Tags for Releases

git tag -a v1.0 -m "Release v1.0"


git push origin v1.0

10. Advanced Tools

.gitignore: Ignore files


.gitattributes: Text/binary file rules
git stash: Temporarily save changes
git cherry-pick: Apply specific commits

You might also like