[关闭]
@zhengyuhong 2015-04-18T09:52:22.000000Z 字数 1512 阅读 1234

在linux下搭建git github开发环境

github git linux


1、安装git

  1. sudo apt-get install git

2、Generating SSH keys

2.1、generating ~/you/.ssh/id_rsa

此处参考Generating SSH keys @linux

  1. ssh-keygen -t rsa -C "your_email@example.com" #注册github的邮箱帐号
  2. Enter file in which to save the key (~/you/.ssh/id_rsa): [直接按回车默认位置存放公匙密匙]
  3. Enter passphrase (empty for no passphrase): [输入通行证别名(用于记录刚刚产生的公匙密匙),我是使用github]
  4. # Enter same passphrase again: [again]

2.2、Add your SSH key to your account

  1. 将刚刚产生的~/you/.ssh/id_rsa中最后一个公匙拷贝到https://github.com/settings/ssh

参考
Generating SSH keys @linux
Linux下Git和GitHub基本使用

2.3、Test the connection

  1. ssh -T git@github.com
  2. #输出Hi username! You've successfully authenticated, but GitHub does not
  3. # provide shell access.即表示连接成功

  If the username in the message is yours, you've successfully set up your SSH key!
  

3、本地配置

  1. git config --global user.name 'username'
  2. git config --global user.email 'your_email@example.com' #全局联系方式,可选

  执行完之后会自动新增~/.gitconfig,里面就是内含上述的信息。

4、同步github仓库到本地

第一步: 到GitHub的某个仓库,然后复制右边的有个“HTTPS clone url”
第二步: 回到要存放的目录下,使用命令 "git clone https://github.com/chenguolin/scrapy.git",红色的url只是一个例子
参考

5、本地同步到github

5.1、同步clone下来的仓库到github

  1. git add *
  2. git commit -m "update message"
  3. git push -u origin master
  4. #输入帐号密码

5.2、新建本地仓库同步到github

  按照如下方法

  1. mkdir testdir & cd testdir
  2. touch README.md
  3. git init #初始化一个本地库
  4. git add README.md #添加文件到本地仓库
  5. git rm README.md #本地倒库内删除
  6. git commit -m "first commit" #提交到本地库并备注,此时变更仍在本地。
  7. git remote add origin git@github.com:zhengyuhonog/testdir.git #增加一个远程服务器的别名。
  8. git push -u origin master #将本地文件提交到Github的remoname版本库中。此时才更新了本地变更到github服务上。

  但是一直发生reporteries not found 错误,所以只好先在网页上新建仓库。然后同步下来再使用5.1的方法。

6、参考

linux下git与github简单使用
Linux下Git和GitHub使用方法总结
Linux下使用git命令及github项目

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注