Ubuntu Git安装与使用
来源:互联网 发布:材料数据库 编辑:程序博客网 时间:2024/04/30 02:16
文章链接: http://blog.csdn.net/yhl_leo/article/details/50760140
本文整理和归纳了关于Ubuntu中Git安装与使用的资源,希望对大家有所帮助。
1 安装
安装方式主要有两种,即通过Apt
和source
:
1.1 通过Apt
安装:
官网上提供的命令是:
$ sudo add-apt-repository ppa:git-core/ppa
中间暂停时,按回车键Enter
继续安装。
$ sudo apt-get update$ sudo apt-get install git
安装下载完成后,可以使用下面的命令行,确认git
的版本:
$ git --version
1.2 通过Source
安装
首先,安装一些git
依赖的软件:
$ sudo apt-get install build-essential libssl-dev libcurl4-gnutls-dev libexpat1-dev gettext unzip
安装完成后,可以在GitHub上公布的Git Project,选择Tags
中的最新版本2.7.2:
复制下压缩文件的下载链接(Downloads按钮鼠标右键):
使用命令行下载:
$ wget https://github.com/git/git/archive/v1.9.2.zip -O git.zip
解压,并路径转换到git
下:
$ unzip git.zip$ cd git-*
编译源码:
$ make prefix=/usr/local all$ sudo make prefix=/usr/local install
编译完成后,同样可以利用上述的语句查看git
版本。
如果,后面还想继续更新,可以这样:
$ git clone https://github.com/git/git.git
访问的链接(URL)可以在上述的GitHub项目中拷贝:
然后像上面一样,编译源码:
$ make prefix=/usr/local all$ sudo make prefix=/usr/local install
就会在git
安装位置重装和重编译新的版本(会将旧版本覆盖掉)。
2 git
入门
2.1 配置git
首先,是指定用户名和邮箱:
$ git config --global user.name "Your Name"$ git config --global user.email "youremail@domain.com"
可以如下查看配置信息:
$ git config --list
2.2 创建一个本地repository
创建一个名为myGitTest
的repository
:
$ git init myGitTest
然后切换,文件路径到myGitTest
:
$ cd myGitTest
依次添加文件README
和sample.cpp
$ gedit README$ gedit sample.cpp
在README
文件内随便写入一些内容:
This is my first Git and GitHub test conducted on my Ubuntu Wily system.
同理,在sample.cpp
中写入一段代码:
#include <iostream>int main(){ std::cout << "Hello Git!" << std::endl; return 0;}
将这两个文件通过git
添加到刚刚创建的myGitTest
:
$ git add README$ git add smaple.c
现在,将myGitTest
的变化更新情况提交:
$ git commit -m "create a git project"
2.3 同步到GitHub
在GitHub个人账户中,创建一个repository
(我已经创建过了,所以会提示已经存在):
将新创建的repository
的URL拷贝:
使用下面的命令,将本地的repository
提交到GitHub:
$ git remote add origin https://github.com/yhlleo/myGitTest.git$ git push origin master
接着会提示输入GitHub的账户名和密码,输入就可以完成:
登陆到GitHub上,打开myGitTest
如下:
- ubuntu GIT 安装与使用
- Ubuntu Git安装与使用
- Ubuntu Git安装与使用
- ubuntu GIT 安装与使用
- ubuntu下git安装与使用笔记
- ubuntu下git安装与使用笔记
- ubuntu下git安装与使用笔记
- ubuntu下git安装与使用笔记
- ubuntu下git安装与使用笔记
- Ubuntu下Git安装与使用
- Ubuntu下git安装与使用
- Ubuntu下git安装与使用
- ubuntu下git安装与使用
- Ubuntu下Git的安装与使用
- Ubuntu 中git的安装与使用
- Ubuntu下的Git的安装与使用
- Ubuntu 12.04 下git的安装与使用
- Ubuntu Linux环境下git的安装与使用
- Activity的状态保存
- JSOUP选择器语法说明
- java生产者消费者
- 花相似,人不同—组长篇
- struts.properties核心文件
- Ubuntu Git安装与使用
- 用SVG制作 Button 点击特效实例
- Win7-64bit下matlab C混合编程环境搭建
- sklearn学习笔记3——pipeline
- vs2013+tesseract配置
- 联合查询中要注意要有索引
- Android中的ViewPager(二)
- 【bzoj2002】【LCT】弹飞绵羊
- android平台上耳机缓慢插入时图标显示后又消失的bug