Git Flow
- Master/Main Branch is always production-ready.
- Feature Branches are created to develop new features without disturbing the main branch.
Git Flow Lifecycle
- Create a Pull Request (PR) of feature branch into main branch.
- Team reviews pull request
- Comment
- Request changes
- Implement, commit, and push changes
- Teammates approve (or reject)
- Merge into main
Git Flow Lifecycle
Create a feature branch from main
git checkout main
Fetch latest changes
git pull
Create new branch (follow suggested naming guidelines)
git checkout -b feature/my-new-feature
Implement and commit changes
git add .
git commit -m "Implement my new feature"
Push branch to remote 'origin'
git push
Pull requests
- Allows team members to review code changes before they're merged.
- See a clean diff
Merge Conflicts
- Merge conflicts happen when git cannot automatically merge changes.
- Merge conflicts are caused by overlapping changes.
- Identify the conflicted areas and decide which code stays, which code goes.
- Commit the resolved changes.
Best Practices
- Regularly pull changes from main branches.
git pull origin main
- Keep feature branches focused and short-lived.
- Clear and descriptive commit messages.
Git Commands & Flow
Check your current branch. Understand where you are.
git branch
Switch to the 'main' branch before creating a new feature branch.
git checkout main
Pull the latest changes from the remote repository
- always do this before creating a new branch to ensure you're up-to-date
git pull origin main
Create a new feature branch:
git checkout -b feature/cuisine-filter
Make changes & commit:
git add .
git commit -m "Implement cuisine filter functionality"
Push your feature branch to the remote repository.
git push origin feature/cuisine-filter
Switch between branches (eg move back to main).
git checkout main
Update your local branch with the latest changes post-merge (always good to stay updated).
git pull origin main
Make sure to set configuration to resolve conflicts using merge
git config pull.rebase false
Top comments (0)