Github? (My First Post)

For my first blog, I will talk about something really important for developers, let’s get into this!

Let mind = document.getElementbyId(“Knowledge”);

THE INITIATE

initiate

You’ve probably heard about Github. If you never did, here is the chance, so what is it?

Github is a platform for developers, similarly to Facebook and Twitter is a social network where instead of posting duck faces and other technically “useful” content, well, guess what? We “post” sources codes of projects. But Github ideology doesn’t stop here. Now you know that you can post some code in there. Let me explain you more profoundly what is it all about.

WHAT IS GITHUB?

octocat It is a version control system (originally applied for command Git). As a developer or a Computer Science student, you probably had encounter situations where you have to develop a software or any kind of system and at the same time, you keep editing it until getting the “perfect” version and sometimes you collaborate with some people. But it keeps frustrating to manage all the version made by everyone, even by yourself. That’s how Github manages this problem; keeping records of every changes and version made to a software in such a way you can manage them without confusion.

Another feature of Github is acting like a time-travel machine. You can move back and forth in the version you put on the platform. Remember back to the future!

Marty McFly: Wait a minute. Wait a minute, Doc. Ah… Are you telling me that you built a time machine… out of a DeLorean?

Dr Emmett Brown: The way I see it, if you’re gonna build a time machine into a car, why not do it with some style?

GETTING STARTED

On windows, I recommend using Bash on Windows (Linux Subsystem).

Those using Linux, well, you can just open your favourite terminal.

Once done, use your favourite package manager to install git.

For Debian-based Linux OS, such as Ubuntu you can try these: sudo apt-get install git

Now you have installed git, we now go into some command. Oh Yeah!

Let’s create your git credentials: ` git config –global user.name “Your Name, your real name”

git config –global user.email “[email protected]

git config –global user.username “Your github username” `

These commands above help when you are pulling****request on Github, and who are the authors. (We will get back to that later)

First off, create a directory.

mkdir hello-world

The command mkdir will create a directory where we will make the magic happens.

Afterwards, go to the directory using cd meaning change directory.

cd hello-world

Now you are inside the directory, we will initialize Git to track changes in this particular directory.

git init

You can put a file in it, like a text file and write some words in it and save. You can use nano, vi, or any particular editor you feel acquainted with.

Use this command:

git add -A

Now it starts to be serious, this command above will add the file to git tracking system. Imagine a checkpoint in a game. The same thing is applied here, except the command saves the current modification you had previously. The flag -A just stands for All. So you keep track of every file in the directory.

You can now use : git status

To see the status of the file added.

You will see something like: Changes to committed

commit

This means that you save to the checkpoint, but you haven’t yet finalised your changes, to achieve that you should do this: git commit -am "Added hello-world"

As previously said for -A, the flag -a does the same thing and it can be unnecessary.

The -m flag stands for the message, that’s why a flag is followed by this message, to give a name to the finalised changes done.

Finally, you know how to “commit” changes, i.e to finalize your changes to the code. Next step is how to send it to the Github, the platform I talked so much about.

Don’t close your terminal, we are not done yet.

TO INFINITY AND BEYOND!

Now you can go on Github and create your account.

Screenshot from 2017-12-11 23-23-47

After you done that, you just have to create a repository.

index

Name it for ex. hello-world, and done you will see, a page a bit like this.

d

Open the terminal, then type this: git remote add origin www.github.com/YOURUSERNAME/REPOSITORYNAME.gitA similar code can be found on the page loaded after you’ve created your repository. Replace YOURUSERNAME with the username you used to for your Github profile and REPOSITORYNAME is replaced by the name of the repository you recently created

The command will tell git that you want to put all the files contained in the directory hello-world, in the repository you created earlier.

Last but not least, git push -u origin master

Afterwards, you will be prompted for your username and password, you just need to fill it and done! Go to Github and go to your profile to see the difference.

Next tutorial will be about PULL REQUEST.

Stay tuned and follow busymind101.