GitHub Workflow (GitHub Flow) – Step by Step
What is GitHub Workflow?
GitHub Workflow (GitHub Flow) is a simple branching model where developers create a feature branch, make changes, push to GitHub, create a Pull Request, review, and merge into main branch.
Step 1: Clone Repository
git clone https://github.com/user/project.git cd project
This downloads the project from GitHub to your local machine.
Step 2: Create Feature Branch
git checkout -b feature-login
A new branch is created for your work so main branch stays stable.
Step 3: Make Changes and Commit
git status git add . git commit -m "Added login feature"
You save your changes locally with a commit message.
Step 4: Push Branch to GitHub
git push origin feature-login
Your feature branch is uploaded to GitHub.
Step 5: Create Pull Request (PR)
On GitHub website:
- Open repository
- Click Compare & Pull Request
- Add description
- Click Create Pull Request
PR is used for code review before merging.
Step 6: Code Review & Approval
Team members review code, suggest changes, and approve PR.
Step 7: Merge Pull Request
After approval, PR is merged into main branch.
Step 8: Pull Latest Code
git checkout main git pull origin main
Your local main branch is updated with merged code.
Handling Merge Conflict
<<<<<<< HEAD
System.out.println("Hello");
=======
System.out.println("Hi");
>>>>>>> feature-login
Resolve conflict manually, then:
git add file.java git commit -m "Resolved conflict"
Complete GitHub Workflow Diagram (Text)
Developer → Feature Branch → Push → Pull Request → Review → Merge → Main Branch
Advantages of GitHub Workflow
- Main branch always stable
- Easy collaboration
- Supports CI/CD easily
- Simple to understand
Important Git Commands
| Action | Command |
|---|---|
| Clone | git clone URL |
| Create branch | git checkout -b branchname |
| Add files | git add . |
| Commit | git commit -m "message" |
| Push | git push origin branchname |
| Pull | git pull origin main |
| Merge | git merge branchname |
Source: sureshtechlabs.com