Friday, September 21, 2012

Git Basics and Using Github

Hi, this blog entry is for beginners who want to try out Git and GitHub. I am setting up this on Ubuntu .

What is Git and How is setting Up with Ubuntu? :


Git  is a distributed revision control and source code management (SCM) system with an emphasis on speed. Git was initially designed and developed by Linus Torvalds for Linux kernel development.


Setting up Git in your system:

First install Git in your machine, Enter the command seen in Below in terminal(Alt+Shift+T):









You can test the installation by simply typing git.It should print out the instructions of Git

 












If you don't see this.then try to install Git again



Configuring Git:


We can configure Username and Email ,Using following these commands:



Test your configuration by giving the  command below or typing "git config -l":



 




  
Creating your first Git repository and playing with it:

 From your my_project directory type git init to create a git repo .



   The message shows that a Git repo has been created successfully.if you can do "ls -a",then you can see a folder named ".git" .

Create a Directory and make a file 'a.c'(I think you have the basic knowledge of VIM editor.other wise you should use any text editor for making files) in it, using the command:




 
Add the file a.c into the repo with following command "git add file_name". Once the file has been added it will be tracked by Git.Remember that whenever you make a change that is to saved , you have to commit it .This can be done using the "git commit" command:











what is GitHub??:


GitHub is a web-based hosting service for software development projects that use the Git revision control system. http://github.com/


Making your repo global-Connecting to GitHub:

Lets now see how to connect our local repo to the world using Github.First of all you need to sign up at  github.com .
Click Here for free signup in Github.
Once you have finished with that , next step is to set up the SSH Keys. Just type "ssh-keygen -t rsa your email id". Next you will be asked to enter the location where the generated ssh key must be saved , after that enter a secure passphrase twice. Then you should see something like this as output.

























Open id_rsa.pub file from the given location .ssh in Home directory and copy it contents.
 ssh public key is like below:










Now log in to the github id you created . go to account settings >> SSH Public Keys >> add another public key.Paste the copied key into the form and click add key





























You can Verify by giving the command  ssh -T git@github.com .












We have successfully connected the github account  to your local system.Now we can push/pull  code to the repo in Github. 

How to push a code to Github repo??.



firstly create a repo in your Github account. just click the new repository tab in your web page and give a name to your repository. after successfull creation the http adress or the ssh address is just copy.it is your remote Github address .
Then make a directory in your system and intiate a git in it using the below commands and add files in the directory.then add to git and commit the file.















Next is access the remote location and push the code to Github:














The code pushed to Github is is here:























we have success fully push the code to Github!!!!!!!!

 

No comments:

Post a Comment