Thursday, November 3, 2016

GitHub – The Basics 2/2

It’s play time !!!
Make sure you have your environment ready as I showed on the last post before proceed.

-       Create Repository
Let’s start creating a Repository, it’s like a folder where you keep all the files related to a specific project.
Once logged, there are several places to create a new repository, even a button called “Start a project

Just give it a name, mark it “Public” and click “Create repository”;

for this tutorial I’ll call mine basicsguide.

Most of the time you are working offline and then from time to time you sync your changes with an online repository
As a best practice, create a folder for each single project you are working with.

 -       Initiate Repository
You need to tell Git what’s the folder you want to work with. (it will be your current directory)
Run: git init

Now you can start working on your offline repository, creating or adding files to it.

 -       Check Status
At any time you can check the status of your offline repository, it will show you what files were added, deleted or modified.
I just created a dummy file called hello.txt for the purpose of testing.
Run: git status


-       Add Files
Before commit your changes you need to say what files you want to commit
Run: git add “file_name” (for single file)
Run: git add * (for all files reported by the status command)

As you can see the file color changed from red to green, meaning it’s ready to commit

-       Commit a file
Now let’s commit the changes, adding a description is a nice touch
Run: git commit –m “description for the changes”

-       Add Remote Repository
At this point all your changes still local to your offline repository, let’s add a online repository to work with and sent your updates to

-       Push Content
Now it’s time to send your commits to your online repository
Run: git push -u “name” “branch”
As it’s a simple tutorial I’m using the master branch, if you want to learn more about branches here’s a nice article

 If you go back to the webpage you will see that the new file got updated with the commit description you just set.

-       Pull Content
Now if some else is working on your project and submit changes to your online repository, you can sync it with your offline repository  (for the sake of testing I did a small change to the hello.txt file through the webpage, not showing it here.)
Run: git pull

-       Clone Repository
Now the cool stuff !!! 
if you want to work with some else repository you can just clone it to a offline repository of yours
Run: git clone “repository_address”

In this case I’m working with vmware/powernsx project.
As said before, I created a new empty folder and as expected after cloning all the files were available on my offline repository.

Congratulations you just gave the first step into this new world.
As a homework, why dont you try to clone my project ( and add your name to hello.txt file ?!?
I’m planning to add more advanced posts in the future, meanwhile you can check the GitHub tutorials, there are a lot fancier features available.

See you.

No comments:

Post a Comment

Who am I

My photo
I’m an IT specialist with over 15 years of experience, working from IT infrastructure to management products, troubleshooting and project management skills from medium to large environments. Nowadays I'm working for VMware as a Consulting Architect, helping customers to embrace the Cloud Era and make them successfully on their journey. Despite the fact I'm a VMware employee these postings reflect my own opinion and do not represents VMware's position, strategies or opinions.

Most Viewed Posts

Blog Archive