在linux下搭建git github开发环境
github git linux
1、安装git
sudo apt-getinstall git
2、Generating SSH keys
2.1、generating ~/you/.ssh/id_rsa
ssh-keygen-t rsa-C"your_email@"#注册github的邮箱帐号
Enterfileinwhich to save the key(~/you/.ssh/id_rsa):[直接按回车默认位置存放公匙密匙]
Enterpassphrase(emptyfornopassphrase):[输入通行证别名(用于记录刚刚产生的公匙密匙),我是使用github]
# Enter same passphrase again: [again]
2.2、Add your SSH key to your account
将刚刚产生的~/you/.ssh/id_rsa中最后一个公匙拷贝到/settings/ssh
2.3、Test the connection
ssh-T git@
#输出Hi username! You've successfully authenticated, but GitHub does not
# provide shell access.即表示连接成功
If the username in the message is yours, you've successfully set up your SSH key!
3、本地配置
git config--globaluser.name'username'
git config--globaluser.email'your_email@'#全局联系方式,可选
执行完之后会自动新增~/.gitconfig,里面就是内含上述的信息。
4、同步github仓库到本地
第一步: 到GitHub的某个仓库,然后复制右边的有个“HTTPS clone url”
第二步: 回到要存放的目录下,使用命令 "git clone /chenguolin/scrapy.git",红色的url只是一个例子
参考
5、本地同步到github
5.1、同步clone下来的仓库到github
git add*
git commit-m"update message"
git push-u origin master
#输入帐号密码
5.2、新建本地仓库同步到github
按照如下方法
mkdir testdir&cd testdir
touch README.md
git init#初始化一个本地库
git add README.md#添加文件到本地仓库
git rm README.md#本地倒库内删除
git commit-m"first commit"#提交到本地库并备注,此时变更仍在本地。
git remote add origin git@:zhengyuhonog/testdir.git#增加一个远程服务器的别名。
git push-u origin master#将本地文件提交到Github的remoname版本库中。此时才更新了本地变更到github服务上。
但是一直发生reporteries not found 错误,所以只好先在网页上新建仓库。然后同步下来再使用5.1的方法。
6、参考