Saving your work with github.

Just managed to get my hands on github, have created my repository long back, but hadn’t got time to push anything to it. Couple of days back, must give it a try and here I am, tried, worked and got answers for some of my weired questions, writing it so, it can help me later when redoing it and so to others who may face similar challenges.


I am not a hard developer, but then from the net understood git is a better version control system, than others. Hence, I will not go into how it begin and what it does, you sure can find a lot of documentation over the web.

So the quest begin from here.

1. How to create github repository.
A: I will tell you the only way I know. Following through the github’s manual this is how you can create a repostiroy in github.

2. Start working.
A: Create a pair of keys on your Linux Desktop/Laptop(mine is R61 running Lucid).

ssh-keygen -t rsa

This will create a public and private key in your $HOME/.ssh/
You can then just copy the .pub file to your github account and save it there.

Go to Account Settings > SSH Keys > and just copy and paste the content of your id_rsa.pub file in the space provided in the left and save it.

3. Initialize your repository.
A: In your home area or your development area.
– This will initialize your repository where you are working.

git init .

– To add files to your repository

git add * # To add all the files in that repo.
git add *.c # To add only the files with .c as extension, basically the source files.
git add filename # will add this only file to the repository

– To add comment and move on.

git commit -a -m "add comment" # It could be anything from a short description of your changes to something elaborate.

– To check the status of the chnaged files from the initial commit and a new commit.

git status

Now, here comes the most intersting part. Putting your repository to github.com.

4. Comminting and uploading your work to github.
A: Initially all my push to the github was failing, later read somewhere that I need to make the pull request first and then the push will work, so here what i did/.

git pull http://github.com/omps/dotfiles.git # made my first pull to the repo.

Inside my development env.

git init .
git remote add http://github.com/omps/dotfiles.git # Added my github repository  to my local.
git remote -v # This will show you your push and pull origin.

in my case it shows something like this

$ git remote -v
origin	http://github.com/omps/dotfiles.git (fetch)
origin	http://github.com/omps/dotfiles.git (push)

now you are ready to make your first push with the files you added in step 3.

git push origin master

Voilla!!! we are done.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

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