Saturday 12 January 2013

Setting up a git Repository

After finding that Blogger is not the ideal method to post any code I thought it was time to learn how to make a git repository for any my code.

I have used git many times before but only used git to get code from the repository using git clone git:repository.
They say learning from your mistakes help you to learn, then I`ve done a lot of learning with this excise .

If there is a way to get it wrong I`ve made it.  

I had all ready install all the relevant modules for downloading code:
 eg git and git-core.

I followed the instruction from :  

https://help.github.com/articles/set-up-git
https://help.github.com/articles/generating-ssh-keys

Made my key pair because my raspberry pi didn`t have one by default ,   and posted it to the git repository ssh key profile screen.

Tried to load in  with "ssh -T git@github.com" , wow all worked !!!.
I now made my first repository and clicked on the option to add a readme file to start the repository off. 

This is where my mistakes started to come think and fast !!!!


I log in my Pi and did my normal way to download a git:repository using the read only method .

eg with "git clone git://github.com/my_account/project_name.git" big mistake I was later to find.

I started to read this :-
http://git-scm.com/book/en/Git-Basics-Recording-Changes-to-the-Repository

# Made a new file .
git add the_new_file
git commit -m "start off"
git push

from the push, got I you can`t push you "git://github.com/my_account/project_name.git" try using "git@github.com:my_account/project_name.git"

So I guess that was learn one.

I started to make a real project , and made a new project like before , but this time using the ssh address method.
I tried repeating the above excise making a new file , adding the file , committing the file , then pushing the file , wow no problems this time.
Copied my project to the project folder and did a "git add *" .
Them thought that`s a bad idea all my password and key files are still in my code , so for I haven`t committed the files yet, so I can still just remove them before committing the files. It didn`t work that way and after I pushed my files to the repository I could see my password and key files and commit showing the changes to these files.

So I guess that was learn two , Remove any bit you don`t want to be shown before you add them
  
It was delete and start again with 3rd time lucky.

No comments:

Post a Comment