Skip to the content.

What is Git Branch

Git Workflow

Step 1: Initialize the Repository

mkdir test
cd test/
rm -rf .git
rm -rf *
git init
git branch -M main

Step 2: Create readme.md

touch readme.md
git add .
git commit -m "added readme.md"

Step 3: Create and Merge feature-hello

git checkout -b develop main
git checkout -b feature-hello develop
touch hello.html
git add .
git commit -m "added hello.html"
touch world.html
git add .
git commit -m "added world.html"
git checkout develop
git merge --no-ff feature-hello -m "merged feature-hello"
# git merge feature-hello can be used to not to see the branch tree
git branch -d feature-hello

Step 4: Create and Merge feature-userinfo

git checkout -b feature-userinfo develop
touch userpage.html
git add .
git commit -m "added userpage.html"
touch userinfo.html
git add .
git commit -m "added userinfo.html"
git checkout develop
git merge --no-ff feature-userinfo -m "merged feature-userinfo"
# git merge feature-userinfo can be used to not to see the branch tree
git branch -d feature-userinfo

Step 5: Merge develop into main

git checkout main
git merge --no-ff develop -m "merged develop"
# git merge develop can be used to not to see the branch tree

Step 6: Create and Merge bugfix-login

git checkout -b bugfix-login
git checkout -b bugfix-login main
touch login.html
git add .
git commit -m "fixed login.html"
git checkout main
git merge --no-ff bugfix-login -m "merged bugfix-login"
# git merge bugfix-login can be used to not to see the branch tree
git checkout develop
git merge --no-ff bugfix-login -m "merged bugfix-login"
# git merge bugfix-login can be used to not to see the branch tree
git branch -d bugfix-login

Step 7: Add Success and Continue Pages

touch success.html
git add .
git commit -m "continued with success.html"

git checkout develop
touch continue.html
git add .
git commit -m "added continue.html"

git checkout main

Refs: