GitHub and Git Bash, Branch Explanation
Why we have to “branch early and branch often”?
Because branch allow to work in parallel with other teams.
Normally, in a project, we have a master branch, and the develop branch.
Master branch is always the final publish state, and the develop branch is where work.
If we have to release a new version, we merge the develop branch with master branch.
In a rpg videogame project, for example, we have a master branch, a develop branch, and from the develop branch we can start another branch for quest, for inventory, for weapon, so different people can work in different branch, and at the end, commit for merge in develop branch.
Branching is really powerfull!
So, and said in the previous topic, type in Git Bash
git branch
and wee see all the branch
We can type
there is a branch command
which we can use to create, delete or list new branches.
To create new branch, type
git branch dev
where dev is the name of branch
after that, type git branch and we see both branch, dev and master
To switch from master to dev, we can use
git checkout dev
or
git switch dev
As you can see, now we switch from master branch to dev (blue name inside brackets says in what branch we are)
Now everything we make inside dev branch, not affected the master branch.