Skip to content

FirasMosbahi/git-tutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 

Repository files navigation

Git & Github training

Git setup

  1. download git from the link https://git-scm.com/downloads

  2. Configure username and email

git config --global user.name
git config --global user.email

Creating repository

  1. Create repository with
git init  
  1. create a .gitignore file

  2. create your first file

  3. commit the changes

git add text.txt
git commit -m 'first commit'
  1. 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
  1. Setup branchs
git checkout -b staging
git push --set-upstream origin staging

git checkout -b dev
git push --set-upstream origin dev

Create first merge via UI

  1. 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
  1. Create pull request

  2. Pull changes from dev branch

git checkout dev
git pull

Create merge via shell

Push 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-2
git pull origin dev
git merge feature-2

Resolve merge conflicts

  1. 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
  1. Merge branch feature-3

  2. Pull request branch feature-4

  3. Resolve conflicts

git checkout feature-4
git pull origin dev

git status

git add .
git commit -m 'resolve conflicts'
git push
  1. Merge branch feature-4

Release to main

  1. Create pull request from dev to staging and merge it

  2. Create pull request from staging to main and merge it

  3. Add tag

git tag -a v1.0 -m "First release"
git push origin v1.0

make hotfix

  1. 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
  1. Merge to staging

  2. Merge staging into dev

  3. Merge staging into main

Revert changes

git revert {commit hash}
git push

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published