Easy Introduction to Git and Github (Part 2)
Hey, I’m glad you are here, in part 1 of this post I did an introduction to git and GitHub, you might want to check it out before you continue. However, you can just continue with this without going through Part 1.
In this article, we will quickly learn about branches and then do some hands-on activities, I believe you are excited just like me.
What is a branch in git?
I see git branches as individual projects inside a git repo. A branch can have completely different files. Branches come into play when you want to make some changes or a new feature without interfering with the main code. Or maybe you want to experiment with a new feature before implementing it on the main code. Enough!
To check how many branches you have:
git branch -a # you should see something similar to: card_modified * master remotes/origin/HEAD -> origin/master remotes/origin/master
The * shows the current branch you are on. # is commenting out also note that it showed us both local and remote branches.
To create a new branch:
git branch <branch name>
To move into the new branch:
git checkout <branch name>
To delete a branch:
git -d <branch name>
Enough to get you started already. In the next steps, I would love that you do with me. Note: I assume you are using Linux OS some commands might be different for Windows.
1. Create a folder named my_website and cd into it:
symons@symons-macbookair:~$ mkdir my_website symons@symons-macbookair:~$ cd my_website symons@symons-macbookair:~/my_website$
Alternatively, you can create a folder manually and open CMD/ Terminal inside that folder
2. Create two files inside my_website folder.