-
download git from the link https://git-scm.com/downloads
-
Configure username and email
git config --global user.name
git config --global user.email- Create repository with
git init -
create a
.gitignorefile -
create your first file
-
commit the changes
git add text.txt
git commit -m 'first commit'- Push changes to remote repository
git branch -M main
git remote add origin https://github.com/FirasMosbahi/git-tutorial.git
git push -u origin main- Setup branchs
git checkout -b staging
git push --set-upstream origin staging
git checkout -b dev
git push --set-upstream origin dev- Push to feature branch
git checkout dev
git checkout -b feature-1
echo 'text1' > text.txt
git add .
git commit -m 'first feature'
git push --set-upstream origin feature-1-
Create pull request
-
Pull changes from dev branch
git checkout dev
git pullPush to feature branch
git checkout dev
git checkout -b feature-2
echo 'text2' > text.txt
git add .
git commit -m 'second feature'
git push --set-upstream origin feature-2git pull origin dev
git merge feature-2- Create conflict:
git checkout dev
git checkout -b feature-3
echo 'text3' > text.txt
git add .
git commit -m 'third feature'
git push --set-upstream origin feature-3
git checkout dev
git checkout -b feature-4
echo 'text4' > text.txt
git add .
git commit -m 'fourt feature'
git push --set-upstream origin feature-4-
Merge branch feature-3
-
Pull request branch feature-4
-
Resolve conflicts
git checkout feature-4
git pull origin dev
git status
git add .
git commit -m 'resolve conflicts'
git push- Merge branch feature-4
-
Create pull request from dev to staging and merge it
-
Create pull request from staging to main and merge it
-
Add tag
git tag -a v1.0 -m "First release"
git push origin v1.0- Create hotfix
git checkout staging
git pull
git checkout -b H1-hotfix
echo 'text 10' > text.txt
git add .
git commit -m 'hotfix: change text.txt content'
git push --set-upstream origin H1-hotfix-
Merge to staging
-
Merge staging into dev
-
Merge staging into main
git revert {commit hash}
git push