Create a new branch is easy.
There're two methods to create a branch.
I'll show you the easiest.
So, we want to create a branch to fix the logout of our site.
I'll name it fix/logout...
You should have a Branch Naming Convention
git checkout -b fix/logoutWe're now on the fix/logout branch!
Push it the remote repo:
git push --set-upstream origin fix/logoutTo begin, we have to know the branches we have and on which one we are:
$ git branch
* develop
feature/AddComments
feature/Unknown
fix/logout
masterWe have 4 branches:
The asterisk shows us the branch we're currently on.
Now that we know where we are, we can choose where we're going: I choose feature/AddComments.
We only have to write this command:
git checkout feature/AddCommentsAnd we are on the branch!
The deletion of branches is easy, but we have to be careful: a branch have to be deleted locally (on your PC) and remotely (e.g. on GitHub).
We are on feature/AddComments and, for some reason, we abandon the functionality. We should delete its branch then.
First, we have to change branch. Let's say we go to develop:
git checkout developWe can delete the local branch:
git branch -d feature/AddCommentsNow we delete the remote one:
git push origin -d feature/AddCommentsSo, we are on fix/logout and we have to merge it with develop.
To do so, we have to:
git checkout developgit merge --no-ff fix/logoutgit branch -d fix/logoutgit push -u origin developgit push origin -d fix/logoutThere're only three branches left:
$ git branch
* develop
feature/Unknown
masterWe're going to work on that unknown feature but we should rename it.
Indeed the name isn't representative of our feature...
As we want to add articles to the site, let's call it feature/AddArticles.
Because we are on develop, the command is:
git branch -m feature/Unknown feature/AddArticlesIf we were on feature/Unknown, the command would be:
git branch -m feature/AddArticlesNow we have to push the changes:
git push origin :feature/Unknown feature/AddArticlesThen we push the new branch and connect the remote and local branches:
git push --set-upstream origin feature/AddArticles