git安装和基本使用(平台为ubuntu12.04 64bit)
2017-06-14 15:58
429 查看
git的安装方式
1. 通过apt命令安装(简单省事)
sudo apt-get install git2. 编译安装(全局)
从github上下载源码wget https://github.com/git/git/archive/master.zip
解压压缩包
unzip master.zip
进入解压后的目录依次执行编译安装命令
$ make configure ;# as yourself $ ./configure --prefix=/usr ;# as yourself $ make all doc ;# as yourself # make install install-doc install-html;# as root
检查是否安装成功
git –version
3. git 连接到github
生成系统公钥ssh-keygen -t rsa -C”email@email.com”
复制公钥内容粘帖到github帐号管理中的添加SSH key界面中。
sudo gedit ~/.ssh/id_rsa.pub#(复制其中内容)
添加到github SSH key中
使用命令ssh -T git@github.com来验证是否成功。
出现内容:hi xxx. You’ve successfully authenticated, but GitHub does not provide shell access.则说明连接成功。
4. 配置Git,使其能够跟踪谁做了修改
git config –global user.name “bear2flymoon”git config –global user.email bear2flymoon@gmail.com
使用git与github管理代码
1. 将github上的某个代码库clone到本地
$git clone https://github.com/LockeyCheng/BlogSystem-under-Django $cd BlogSystem-under-Django $git add filename.py #添加文件到版本库 $git commit -m 'add filename.py to src' #提交,产生版本记录,注意代码依然在本地 $vim README.md #修改README.md文件内容 $git commit -m 'modify the README.md' #提交,产生版本记录,注意代码依然在本地 $git [remote] rm filename1.py #删除repo中的filename1.py文件 $git commit -m 'delete filename1.py' #提交,产生版本记录,注意代码依然在本地 $git push origin #将修改提交到github上
下图为一个文件删除的示例
首先删除了本地项目文件
然后提交到本地版本库
最后push到github上去
注意:push操作需要输入github账号和密码
2.常用git命令
git help #可查看git的常用命令 git config --global user.name "Your Name Here" #设置commit的署名 git config --global user.email "your_email@example.com" #设置commit的email git config [--local|--global|--system] --list/-l #查看本地的global信息 git config [--local|--global|--system] --unset[-all] user.name #删除user.name信息。如果user.name对应多个值,可用unset-all来删除 git remote add XXX https://github.com/username/repo_name.git #设置github的连接 git clone git://github.com/your_account/aimed_repo.git #复制一个repo到本地 git remote -v #查看本地设置的url连接信息 git status #查看当前工作的 branch git branch #查看本地所有的 branch git branch -a #查看远程的所有分支 git branch -d branch_name #删除本地branch_name这一分支 git push origin --delete branch_name #删除名为branch_name的远程分支 git checkout branch_name #切换到名为branch_name的分支上 git chechout -b branch_name #在本地新建一个名为branch_nam的分支 git diff test_branch_name #查看当前branch与test_branch_name中代码的区别 git mv filename newfilename #文件重命名 git push XXX branch_name #上传指定的branch到远端 git pull #将远程上的版本与本地版本进行合并,相当于get fetch + git merge git reset --hard #将刚才进行的git pull所进行的操作取消,恢复本地版本合并前的原貌
4. 如何删除github上的repository
如果想删除了一个名为BlogSystem-under-Django的repo。则需先点击进入“BlogSystem-under-Django”,单击“Settings”,找到“Delete this repository”,确认删除即可。注意:github上的repo删除后就不能恢复了!5. git clone/push时出现错误提示:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed while accessing …
这是由于ssl认证出问题引起的错误。有两种简单的解决方法:1. 使用命令,成功执行后,便可正常使用git clone和git push了
git config –global http.sslVerify false
2. 使用命令,但每次clone 和 push时都需要带上env的部分。
env GIT_SSL_NO_VERIFY=true git clone https://github.com/XXXX/xxxxx.git
就到这了,所有步骤均为博主实际操作之经验,如果疑问请发邮件到937169083@qq.com进行讨论
相关文章推荐
- Git的基本使用和安装
- Win7平台Git的安装使用
- 使用Gitblit在Windows平台上安装与配置Git Server
- Git 安装及基本使用
- Ubuntu12.04 GIT安装和使用
- go git 安装配置与使用 (windows 7 64bit)
- go git 安装配置与使用 (windows 7 64bit)
- Git安装及基本使用
- go git 安装配置与使用 (windows 7 64bit)
- Ubuntu12.04安装git及github使用
- Git的基本使用方法和安装&心得体会
- Git安装及基本使用
- git的安装与基本使用方法
- git的安装与使用(一)--windows平台 .
- 大数据之Hadoop平台(四)Centos6.5(64bit)Hadoop2.5.1、Zookeeper3.4.6、Hbase0.98.6.1安装使用过程中错误及解决方法
- Git安装、使用教程、遇到的问题和基本常用命令合集
- 使用Gitblit在Windows平台上安装与配置Git Server
- gerrit及git的基本安装使用
- win10 +Git2.10.2-64bit 安装+入门使用(1)