ubuntu环境安装git
来源:互联网 发布:c语言if是什么意思 编辑:程序博客网 时间:2024/05/16 23:41
本文参考ubuntu环境安装git
1. 安装Git
1.1 Ubuntu12.04下
可以使用apt-get方式安装,也可以下载源代码安装【1】,我们这里使用apt-git安装。
但由于直接使用 sudo apt-get install git
安装的版本较老,因此我们参考【2】中给出的PPA源。
sudo add-apt-repository ppa:git-core/ppasudo apt-get updatesudo apt-get install git
安装完成后,检查是否安装成功
git --version
显示 git version 2.1.1,表明安装成功。
2. 设置Git
(1)设置用户名和email。
git config --global user.name "Your Name"git config --global user.email "youremail@domain.com"
此时,Home目录下会新建一个.gitconfig文件
3. 为GitHub账号添加SSH Keys
以公钥认证方式访问SSH协议的Git服务器时无需输入口令,而且更安全。(访问HTTP协议的Git服务器时,比如提交修改,每次都需要输入口令。)
(1)创建SSH key
$ ssh-keygen -t rsa -C "youremail@163.com"
系统会提示key的保存位置(一般是~/.ssh目录)和指定口令,保持默认,连续三次回车即可。
(2)Copy SSH Key
然后用vim打开该文件,id_rsa.pub文件内的内容,粘帖到github帐号管理的添加SSH key界面中。
vim ~/.ssh/id_rsa.pub
(3)添加到GitHub
登录github-> Accounting settings图标-> SSH key-> Add SSH key-> 填写SSH key的名称(可以起一个自己容易区分的),然后将拷贝的~/.ssh/id_rsa.pub文件内容粘帖-> add key”按钮添加。
(4)测试
ssh -T git@github.com
4. 为GitHub上的Repository提交修改
(1)git clone已存在GitHub上的Repository。(在新建的~/MyTestFolder目录中)
git clone https://github.com/zhchnchn/ZhchnchnTest.git
(2)修改一个文件,然后提交
vim README.mdgit statusgit add README.mdgit statusgit commit -m "Edit by WorkUbuntu 1204"git statusgit remote add origin https://github.com/zhchnchn/ZhchnchnTest.git
这时会报错误:
fatal: remote origin already exists.
解决办法【3】:
$ git remote rm origin
然后再次执行 git remote add origin https://github.com/zhchnchn/ZhchnchnTest.git
(3)之后,需要将修改push到GitHub上
git push -u origin master
执行该条命令后,会要求输入GitHub账户的用户名和密码。
(4)提交完成后,查看GitHub上的Repository,会发现内容修改成功。
Refer
【1】How To Install Git on Ubuntu 14.04(https://www.digitalocean.com/community/tutorials/how-to-install-git-on-ubuntu-14-04)
【2】Installing Latest version of git in ubuntu(http://stackoverflow.com/questions/19109542/installing-latest-version-of-git-in-ubuntu)
【3】Ubuntu12.04下安装Git(http://blog.csdn.net/biosd/article/details/9115837)
【4】CentOS6.6源码安装git-2.3.0(http://blog.csdn.net/goritcly/article/details/43878209)(http://www.centoscn.com/image-text/install/2015/0225/4735.html)
- ubuntu环境安装git
- ubuntu环境源码安装git服务
- 【git】ubuntu安装git
- Ubuntu Linux环境下git的安装与使用
- ubuntu 下安装 git
- Ubuntu下安装git
- ubuntu 安装git
- ubuntu安装git
- ubuntu 安装 git
- Ubuntu 安装git服务器
- Git Ubuntu下安装
- ubuntu安装git
- ubuntu安装git
- Ubuntu安装git服务器
- Ubuntu安装git
- ubuntu git 安装
- Ubuntu安装git
- ubuntu 安装Git
- context bounds
- JAVA的StringBuffer类
- [COCI 2015] kamp 聚会
- hpuoj 1717: 感恩节KK专场——爬楼梯 【规律题】【校赛】
- 油菜花王国——搜索
- ubuntu环境安装git
- GeekHades 非常喜欢的电影
- 《leetCode》:Search a 2D Matrix
- 分治算法之赛程安排问题
- c++11 final与override说明符
- Maven的安装以及eclipse中配置maven
- win10 计算机程序
- 属性中的属性
- HDU-3177 Crixalis's Equipment