IT码农库


Warning: Illegal string offset 'parentstr' in /home/wwwroot/cczh004/wwwroot/include/func.class.php on line 246

Notice: Uninitialized string offset: 0 in /home/wwwroot/cczh004/wwwroot/include/func.class.php on line 246
您当前所在位置:首页 > 栏目不存在

CentOS下git命令行操作(图文教程)

网络 莫失莫忘的博客2016-11-20
Warning: Illegal string offset 'id' in /home/wwwroot/cczh004/wwwroot/show.php on line 80

Notice: Uninitialized string offset: 0 in /home/wwwroot/cczh004/wwwroot/show.php on line 80

Warning: Illegal string offset 'classname' in /home/wwwroot/cczh004/wwwroot/show.php on line 81

Notice: Uninitialized string offset: 0 in /home/wwwroot/cczh004/wwwroot/show.php on line 81
1129
本文主要向大家介绍了一些关于CentOS下git命令行操作,看似复杂,其实很简单的,一起来看看具体的内容吧

这篇文章主要介绍了CentOS下Git操作命令整理,需要的朋友可以参考下

之前使用Github都是使用IDE中的一些git插件,一直想学学git命令行的操作,我是在我CentOS做的,Windows可以安装git shell

(1) 新建一个文件夹,做测试

新建文件夹

(2)将此目录变为Git可管理的仓库git init

这里写图片描述

(3)目录下会多一个.git的文件,使用ls命令查看不到,因为它是默认隐藏的,可以使用ls -ah

这里写图片描述

(4)新建一个readme.txt的文件,并且输入一些内容echo > "xxxx" >readme.txt

这里写图片描述

(5)添加文件

git add readme.txt

这里写图片描述

(6)配置一下git的信息

git config --global user.email"邮箱"

git config --global user.name "用户名"

这里写图片描述

(7)提交git commit -m "说明文字"

这里写图片描述

(8)查看git的日志git log或者git log --pretty=oneline只显示简要的信息

这里写图片描述

(9)回撤版本git reset --hard HEAD^,回撤几次就是HEAD^^^^中的^几次(10)查看版本号git reflog(11)回撤到对应的版本号:git reset --hard 版本号(12)删除已经提交的文件git rm 文件名

(1)首先需要创建SSH Key,ssh-keygen -t rsa -C "youremail@example.com",然后一路回车下去

这里写图片描述

(2)在.SSH目录下会有两个文件,一个是id_rsa,另外一个是id_rsa.pub,对应的一个是私钥,一个是公钥(3)将公钥里的内容添加到你的GitHub账号下

这里写图片描述

大图广告(830*140)