GIT Crash Course: Git Branch
Control Version 101
3 min readDec 19, 2022
Branches with Git
New Branch
git branch dev
Switching between branches
git checkout branchName
git switch branchName
Reverting or Resetting by Branch
where is all my stuff? well, I need to merge first.
# Merge from main to get files from main in dev
git switch main
git merge dev
Inventory Script only exists in two branches (dev and inv) but not in the main.
git status
git add .
git commit -m "Dev and Inventory merged to update dev branch"
git push origin dev
# Main update from dev
git switch main
git pull origin main
git merge dev # make sure everything is updated before merging.
git push origin main # Don't forget to push.
Reverting/Reset Project by branch
git switch main
git log # This will give you all your prior commits. Which we can use as branches.
# Hit q to quit that screen
git switch 736da86f18968b103c437ce4f7ef387bbda1912c
# Not the right branch?
git switch main
git log
# find the right one, copy and press q
# If its the right point where we want to branch from
git switch -c NewBranchName 736da86f18968b103c437ce4f7ef387bbda1912c
Go back to the beginning
#This updated your local project
#reseting to the begining of the day.
git reset --hard 12eb979f8caa869fca75f701794bdc78b828bfd5
#This updated your REPO
#reseting to the begining of the day.
git reset --hard 12eb979f8caa869fca75f701794bdc78b828bfd5
#this only updated main not dev, inv or quest.
git push --force origin main
If you want to know more about me, feel free to connect with me on LinkedIn