Ubuntu9.10安装Git,Git 和Github初次使用

工做环境:Ubuntu9.10.github
A、Git安装
一、申请GitHub账户 xxx ,建立名为new-project的新Repository 

二、安装Git客户端(Linux)
#sudo apt-get install git git-core 
果你已经安装好git那么经过下面命令来更新版本库。git clone git://git.kernel.org/pub/scm/git/git.git

三、 生成密钥对,这样项目能够push到 GitHub上
#ssh-keygen -t rsa -C "xxx@gmail.com"
四、将.ssh/id_rsa.pub拷贝到GitHub网站
五、修改~/etc/.ssh/ssh_config.
  PasswordAuthentication no  去掉#并把 yes改成NO
     HostbasedAuthentication no 去掉#
  IdentityFile ~/.ssh/identity 去掉#
     IdentityFile ~/.ssh/id_rsa 去掉#
                 IdentityFile ~/.ssh/id_dsa 去掉#
                 Port 22 去掉#
    Protocol 2,1 去掉#  
新增:
 Host github.com
 user git 
 Hostname github.com
 PreferredAuthentications publickey
 IdentityFile ~/.shh/id_rsa.pub  添加这个很是重要。

shell执行:ssh-add id_rsa,添加密钥。
六、执行 ssh git@github.com。或者 ssh -v git@github.com 可查看相应的连接debug的信息。
连接成功后:能够见到:Hi fuhao715! You've successfully authenticated, but GitHub does not provide shell access.
         debug1: channel 0: free: client-session, nchannels 1
Connection to github.com closed.
Transferred: sent 2544, received 2888 bytes, in 1.2 seconds
Bytes per second: sent 2065.4, received 2344.6
debug1: Exit status 1
七、Config用户名以及邮箱: git config --global user.name "Your Name"
     git config --global user.email fuhao-715@163.com
        
下一步:
   mkdir GoProject
cd GoProject
   git init
  touch README
   git add README
   git commit -m 'first commit'
  git remote add origin git@github.com:fuhao715/GoProject.git
  git push  origin master

# vi README  // 注解 新文件 直接vi保存后,须要git add文件,而后加入 git commit -m  再 git push  origin master

更新至远程
# git push origin master
相关文章
相关标签/搜索