The Magic of Version Control — Part III Branching and Merging

Create and switch to the branch

git branch nameofyourbranch
git switch nameofyourbranch

Add, commit and push it

git add .
git commit -m "added something to dev"
git push origin dev1

Merge it back to the main branch

git switch main
git merge dev1
git push origin main

Summary of used commands

  • git branch — checks which branch is active
  • git branch nameofbranch — creates the nameofbranch branch
  • git push origin nameofbranch — pushes your local branch to the remote repository
  • git switch whatever — switches to the whatever branchg
  • git merge nameofthebranch — you need to be in your main (or whatever branch you want to add your development branch to)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Andrea Zilio

Andrea Zilio

Passionate Game Developer and Learning Expert. I love to create games and interactive experiences using Unity, Articulate, C#, JavaScript, PHP, HTML, CSS.