Symons
Passionate developer with 3 years of building web apps with python Django. Symons is a graduate from Maseno University with Bsc Computer Science degree. He is mostly happy when his students make strides

Git Branch | 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 git branch and then do some hands-on activities, I believe you are excited just like me.

What is git branch?

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.

Create a new branch:

git branch <branch name>

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.

git

Paste the following inside the two files.

#index.html

<!DOCTYPE html>

<head>
    <title>My website</title>
    <link rel="stylesheet" href="style.css">
</head>

<body>
    <h1>I'm Learning Git and Github</h1>
</body>

</html>

#style.css

body{
    background-color: mediumseagreen;
    color: white;
}

We have created an HTML file and CSS file if you don’t understand them, relax its not part of this series but I’ll surely write something about them

Save and take rest. I thought I could do everything in one post but it is getting long. I don’t want it to get boring past here.

in Part 3 we will create a remote repository and connect it to our local folder. we will use, git push to push our changes online. we will then host. see you then.

close

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *