DEV Community

Samuel Lubliner
Samuel Lubliner

Posted on

Git

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

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay