If you are or want to be open source developer,you must try GitHub. It is a new hosted Git repository service that's being called a "social network" for programmers. It is basically a distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
So, you have created your account at github and now you want to work with it from your terminal.
Before you start installing Github, you should set up ssh keys:
$cd ~/.sshif it says "bash: cd: ./.ssh:No such file or directory",it means its not generated and you should continue with step 2. But if it changes to ~/.ssh directory, continue from step 3.
- open your terminal any type
$ssh-keygen -t rsa -C "firstname.lastname@example.org"you will get following lines: 'Generating public/private rsa ket pair. Enter file in which to save the key(/Home/ubuntu/.ssh/id_rsa):' just press enter now it will ask you to enter passphrase note that passphrase you enter must be >4, otherwise you will have to repeat whole process again.
- Backup and remove existing SSh keys type 'ls' it should show you some files like now type these following commands one by one
$ mkdir key_backup $ cp id_rsa* key_backup $ rm id_rsa*
- Adding your ssh key to Github
$gedit id_rsa.pubcopy its entire content. Open github site and login. go to “Account Settings” > Click “SSH Public Keys” > Click “Add another public key” an paste it into "key field". then press Add key.
In your terminal type following command
$ sudo apt-get install git-core git-gui git-doc
Working with git...
In terminal type
$ git clone email@example.com:username/projectname.git
to download a local copy of your code branch. You'll need to replace "username" with your GitHub user name and project name with the name of project on github.
To configure git:
Setup git with your name and email address
git config --global user.name "Your Name"
git config --global user.email "firstname.lastname@example.org"
Modify or create a file and then push it to your project fork on GitHub.
git add new_or_existing_file.c
git push origin master
git fetch upstream
git merge upstream/master
Here are some useful queries you can do to see the git state of things:
- git remote -v to see your fetch and push remotes
- git status to see what you have recently changed
- git log to see a list of all committed changes done to your fork
- git log --stat a more detailed list of all committed changes done to your fork
- git log --graph --full-history --all --color --pretty=format:"%x1b[31m%h%x09%x1b[32m%d%x1b[0m%x20%s" a colorful text-base graph of changes. See image on the right.