Setting up a github project: A-Z

Setting up a github project

First create a github accound accross your gmail(my preference) account.
Now go to your Dashboard at the top part of your account home page.
you will see a link for “Create a Repository”.
Click on it.

Project name is the name you assign for you project, prefer it to have no white-space.
Description – fill it as descriptive it can be.
Now, create Repository.

Now, in your home page you can see “Public Repositories” and your Project Listed below that.
Click on the Project.

You will see two URLs namely, Public Clone URL and Your Clone URL.
Now we want this Your Clone URL, which will be

git@github.com:username/ProjectName

Now we are going to set the project on our Machine, which i am assuming to be kUbuntu9.10 for the time being.

Before that let me tell you something,
GitHub is highly secured and follow ssh-rsa
So we need to setup as ssh public key for our connection, and let github know about it.

take terminal and as user ( not root, usually many of us have a habit of typing sudo su as the first command at terminal, this time avoid it)
type

ssh-keygen -t rsa -C "yourmailid@gmail.com"

here key is generate against your mail id as a string

Here,
-t -> tells which encryption
-C ->try to use the same mail id you have given to github (for ease of memory)

now you will get two files
id_rsa and id_rsa.pub in ~/.ssh/

now copy the whole content in file id_rsa.pub without altering the content of the file.

Now go back to you github account.
go to account settings >>> SSH Public Keys
Add a new Key
and paste the content you copied into field “key” and save (give a title of your choice).

now github know to process the requests from your system.

now try

$ssh git@github.com

this must return

PTY allocation request failed on channel 0              
ERROR: Hi UserName! You've successfully authenticated, but GitHub does not provide shell access                                                              
                 Connection to github.com closed.

ignore this error, that is not an error.

but make sure , it shows Hi! UserName

okay! now we are going to set the repositories local copy on our machine and reflect changes at the remote system

make a directory ( as user, not root )

mkdir MyProject
cd MyProject
git init

( initialize an empty git repository there, see for a hidden folder .git/ there.)

after creating files in MyProjects, when you feel like adding it to your repository at github, do

git add

now run status and check the files you are going to commit next,

git status
git commit -m "Your comment about this commit"

( this updates .git/ folder in your local repository )

now we tell git about the remote repository to be updated

git remote add origin git@github.com:username/ProjectName

( you remember from where we got this URL, its Your Clone URL )

git push origin master

now we are done.
Go and check your github account, and the project in it,
You will see new files, and changes in the existing files, reflecting there.
Now explore more about Git – the fastest Subversion system.

Advertisements

2 thoughts on “Setting up a github project: A-Z

  1. This is a great, clear explanation on how to rapidly get started on GitHub. My question is…after you setup the master branch and start doing development, would you want to commit back to master or somehow create a branch?

    • It’s a usually practice to branch first and then merge back when your feature is ready. And various companies have their own way of managing them.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s