git的出现让传统的svn陷入尴尬的境地,分布式的版本控制是局势所需,svn目前也称要支持分布式,但至今依然是浮云。下面介绍安装git与简单实用,以github做例子。
安装
最简单,可以直接下载资源包,然后安装就好,如果是centos,可以实用yum命令安装:
1
|
# yum install git git-gui |
注册github
打开github站点github.com根据提示注册就好,免费的
导入公钥
首先,要生成公钥
1
|
# ssh-keygen -t rsa -C "你注册github所用的邮箱地址" |
查看公钥
1
|
# cat ~/.ssh/id_rsa.pub |
复制它,然后在github右上角点击设置按钮
点击左侧菜单栏的 SSH keys 项,打开SSH keys 管理页面,然后在key管理页面中点击 Add SSH key 添加公钥
在弹出的dialog中,Title随意填写,key栏复制你在linux机器上创建的公钥
账号配置
1
2
|
# git config --global user.name "用户名" # git config --global user.email github注册的邮箱地址 |
配置好了以后,执行以下命令校验
1
|
# ssh git@github.com |
如果提示:
1
2
3
|
PTY allocation request failed on channel 0 Hi lizhong8532! You've successfully authenticated, but GitHub does not provide shell access. Connection to github.com closed.
|
表示验证通过。
创建github仓库
我们创建一个test仓库
复制test仓库ssh git地址,提交需要用
创建项目目录
1
2
|
[root@localhost ~] # mkdir test
[root@localhost ~] # cd test
|
初始化:
1
2
|
[root@localhost test ] # git init
Initialized empty Git repository in /root/test/ .git/
|
创建README.md文件
1
|
[root@localhost test ] # echo "这是一个测试的案例" > README.md
|
提交到本地
1
2
3
4
5
|
[root@localhost test ] # git add .
[root@localhost test ] # git commit -m "第一次提交"
[master (root-commit) c9206dc] 第一次提交 1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 README.md
|
其中git add . 中的点表示提交这个项目下所有文件,也可以直接指定文件 git add README.md
提交到github
以上,只是提交到本地版本库,github仓库上还没有文件,现在提交到github
1
2
3
4
5
6
7
8
|
[root@localhost test ] # git remote add origin git@github.com:lizhong8532/test.git
[root@localhost test ] # git push -u origin master
Counting objects: 3, done .
Writing objects: 100% (3 /3 ), 255 bytes, done .
Total 3 (delta 0), reused 0 (delta 0) To git@github.com:lizhong8532 /test .git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.
|
其中,git@github.com:lizhong8532/test.git是我的test仓库的提交地址,你需要改成你的test仓库地址就好。
然后刷新你的仓库,就能看见刚才提交的文件了
相关推荐
02.为什么要使用版本控制 03.版本控制介绍 04.Git简史 05.Git优势 06.Git程序安装过程 ...57.安装CentOS7 58.安装Gitlab前的准备和介绍 59.Gitlab安装 60.配置并启动Gitlab服务器 61.浏览器访问Gitlab首页 62.总结
系统环境:CentOS Linux release 7.6.1810 (Core) 起因:npm构建时报错 npm ERR! Error while executing: npm ERR! /usr/bin/git ls-remote -h -t https://github.com/nhn/raphael.git npm ERR! npm ERR! fatal: ...
git-1.7.1-3.el6_4.1.x86_64 这里也已经安装过了,如果没有安装可以用yum install git 安装。 二 创建git用户 这里你可以选择新建一个用户来测试,也可以直接使用你的root进行以下操作。笔者也是看着资料一步一步来...
彻底解决Mac端git clone/push速度太慢的问题,详情请参阅文档。
安装git实例代码,最新2015年12月亲测有效。关于git安装的问题有详细解决方法
操作系统:Centos 7 (纯命令行环境) Git服务器:Github 安装的Git命令行版本:1.8.3.1 整理常用Git命令
CentOS 6.x 上的 Sentry 设置脚本 是一个实时事件记录和聚合平台。 这个脚本让你在 CentOS 6.x 上用 MySQL 和 Redis ...$ sudo git clone https://github.com/y-ken/setup-sentry-centos.git /usr/local/src/sentry/ $
CentOS6.5自带的git版本是1.7.1 卸载自带的git # yum remove git 下载最新版git # wget https://github.com/git/git/archive/v2.9.2.tar.gz 解压 # tar zxvf v2.9.2.tar.gz # cd git-2.9.2 编译安装 # make ...
系统环境:CentOS Linux release 7.6.1810 (Core) 起因:npm构建时报错 npm ERR! Error while executing: npm ERR! /usr/bin/git ls-remote -h -t https://github.com/nhn/raphael.git npm ERR! npm ERR! fatal: ...
centos6-lamp-japanese 在 ... # yum install -y git# git clone https://github.com/ryu-blacknd/centos6-lamp-japanese.git* 这个 Git 是一个旧版本,所以它会被一个脚本取代。然后运行脚本。 # cd centos6-lamp-j
下载$ git clone git@github.com:tmknom/setup-centos.git$ cd setup-centos预设克隆后,用文本编辑器打开 fabfile.py 并进行编辑。 $ vi fabfile.py请务必更改以下项目。工作用户名:USER_NAME工作用户密码:...
服务器 CentOS6.6 + git(version 1.7.1) 客户端 Windows10 + git(version 2.8.4.windows.1) ① 安装 Git Linux 做为服务器端系统,Windows 作为客户端系统,分别安装 Git 服务器端: #yum install -y git ...
git clone https://github.com/mrC2C/cis-benchmark-centOS-8.git 授予脚本的权限: chmod 750 cis-benchmark-centOS-8/centOS8.sh 选项: OPTIONS: -h, --help Display the help message -ls, --list -l, --...
git clone git@github.com/eyasuyuki/ansible-google-cloud-platform-centos6-vagrant.git 初始化流浪者框 cd ansible-google-cloud-platform-centos6-vagrant vagrant init centos6 vagrant up 测试Ansible ...
通过git clone git@github.com:wizardbyron/provisioners.git克隆此git clone git@github.com:wizardbyron/provisioners.git 。 通过[Vagrantfile](/Vagrantfile)自定义您的VM。 通过vagrant up置备您的VM。 平台...
CentOS 6 的 FFmpeg 构建 此 Docker 映像为 CentOS 6 构建静态 ffmpeg 库(和二进制文件)。... git clone https://github.com/geekman/docker-centos-ffmpeg docker build -t zxgm/ffmpeg-build docker-ce
el6-uwsgi-rpm 在 el6(rhel 6 或 centos 6)上为 uwsgi 创建 RPM 的文件。 更新到最新的稳定版本。 基于以下: ...git clone https://github.com/sashkab/el6-uwsgi-rpm.git $HOME/rpmbuild w
要求CentOS (6) 系统,也许其他版本的 CentOS 必须安装daemonize (可以在 EPEL 找到) 确保 EPEL 配置为存储库执行: sudo yum install daemonize安装下载或或使用以下命令克隆此存储库: git clone ...
安装git最新fromm源需要旧的git从github中提取git 提供安装文档的功能只需一个命令即可为我完成所有操作在Ubuntu上检查过| CentOS的安装指南$ sh oneKey.sh[NAME] oneKey.sh -- install Git latest release through...
搭建Git服务器需要准备一台运行Linux的机器,在此我们使用CentOS。以下为安装步骤: 1.下载git-2.22.0.tar.gz https://Github.com/Git/Git/archive/v2.22.0.tar.gz 使用Xftp 把安装包放到服务器上 2、安装git服务...