Lepistina's Code Café

Git, Github and Bitbucket

Written by on August 18, 2016

Hello, y dear friends! I hope you’ve been practicing HTML and CSS a lot since my last post.

Today, I want to talk about sharing your fabulous code with others as well as keeping track of your work in case you ever need to go back in time to a previous version of your work. Git is the system of choice when it comes to keeping track of your progress throughout the development process. GitHub and Bitbucket are leading platforms that allow hosting your projects online using Git. Let’s dive in and see why we need it and how we use it?

 

What is git?

Git is a distributed version control system. Version control is the management of changes to files or projects. It allows you to easily revert a document back to an earlier version or simply see what has changed from version to version. It tracks the changes in files but not files themselves.

 

What does GitHub do?

Github is a hosting site for software development projects that use Git. It has paid and free memberships. Free ones require that you only have open source (visible to everyone) projects.

If you want private membership (visible only to you), you will have to pay, or you can sign up for BitBucket, which has the similar functionality as Github and use Git as a version control system.

 

Getting started:

1) First of all, you need to create an account on https://github.com/

2) Then, install git on your computer, here is a tutorial how to do that depending on what type operating system you have https://git-scm.com/book/en/v2/Getting-Started-Installing-Git

3) Now, when you got it, you need to customize your Git environment. Here is a tutorial how to do it step-by-step, https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup

 

All done? Great, now you can work on your future web app! Let’s say you have already started and you want to store your changes on GitHub, here are the steps you follow:
 
1) In Git Bash, navigate to the folder where your project is located, with command –
– “cd”, Eg: cd [folder where your project is located]
 
2) Then, Initialize it as a Git repository:
git init
 
3) See what’s going on in your repo, it should show you all your files as untracked:
git status
 
4) Add untracked files:
git add filename (for example: index.html)
Or, if you want to add all your files at once:
git add . -A
 
5) Save this state
git commit -m “Here goes message describing what changes you are pushing”
 
6) Then, you should connect your local repo to GitHub:

– You go to your online GitHub Account
– Click on “Repositories”
– Click “New”
– Name it and click “Create repository”
– You have to copy URL displayed there
 
7) Type in git bash:
git remote add origin “paste copied URL” (origin – is what you are naming connection)
git push origin master (master – is the remote branch you’re pushing to)

 

Voila! You just pushed your changes up to GitHub! I suggest to add and commit your changes all the time, don’t wait for days or weeks to accumulate changes. Make it a habit, any change, no matter how small, you have to push it up to GitHub..

 

I hope you enjoyed this article,
I will see you guys soon 🙂

Categories: Coding

Share your thoughts!

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