How to Setup and Use Github in Ubuntu

How to Setup and Use Github in Ubuntu

POSTED IN: TIPS 'N TRICKS
Drupal Performance Review
class="fblikebutton" src="https://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fubuntumanual.org%2Fposts%2F393%2Fhow-to-setup-and-use-github-in-ubuntu&send=true&layout=box_count&show_faces=false&width=49&action=like&font=arial&colorscheme=light&height=61&locale=en_EN" scrolling="no" frameborder="0" allowtransparency="true" style="border-style: none; overflow: hidden; width: 49px; height: 61px; float: right; margin: 11px 0px 5px 5px;">

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.

Github

Setup SSH key....

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:

  1. $cd ~/.ssh

    if 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.

  2. open your terminal any type
     $ssh-keygen -t rsa -C "your_email@youremail.com"

    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.

  3. 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*
  4. Adding your ssh key to Github
    $gedit id_rsa.pub

    copy 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.

Now you have successfully setup ssh key and ready to install github in terminal.

Installation...

In your terminal type following command

$ sudo apt-get install git-core git-gui git-doc

Working with git...

Cloning:

In terminal type

$ git clone git@github.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

  1. git config --global user.name "Your Name"
  2. git config --global user.email "your@email.com"

To do a scripts/reconfig, make, perform some changes to the code, ...

Modify or create a file and then push it to your project fork on GitHub.

  1. git add new_or_existing_file.c
  2. git commit
  3. git push origin master

Occasionally you will want to sync up your fork to the main project branch and pull down any official changes by doing git pull upstream master which is the equivalent of manually doing:

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.
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值