Just Another IT Blog

It's time to share some of my experiences, crazy ideas, tips and tricks !!!

Post Page Advertisement [Top]


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 (https://github.com/emeirell/basicsguide) 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.

Bottom Ad [Post Page]