摘要
本章主要是说一下yum和git的操作
目录
摘要
一、什么是yum
二、yum三板斧
1、list
2、install
3、remove
三、怎么创建仓库
四、git三板斧
1、add
2、commit
3、push
4、pull
五、思维导图
一、什么是yum
YUM是Yellowdog Updater Modified的简称,是杜克大学为了提高RPM软件包安装性而开发的一种软件包管理器。它可以从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软件包,无须繁琐地一次次下载、安装,就像手机里面的应用商店。
YUM提供了查找、安装、删除某一个、一组甚至全部软件包的命令,而且命令简洁而又好记。YUM解决了依赖关系的问题,它可以自动下载软件包所依赖的其它软件包。
YUM软件仓库实际上是根据实际使用中的各种情形,在文件服务器或特定服务器上,将众多的RPM包按照一定合理的分类方式进行整合,同时保持着与官方发布一致性的更新。这样,当需要安装某个RPM包时,可以迅速地在软件仓库中找到并下载到本地进行安装。
总的来说,YUM是一个方便、快捷的软件包管理工具,能够自动处理软件包之间的依赖关系,极大地简化了软件安装的过程.
二、yum三板斧
1、list
通过 yum list 命令可以罗列出当前一共有哪些软件包,如下方截图就是一部分查找到的软件包,因为太多了不好全部截图。
因为太多了,所以我们需要什么就可以利用管道配合grep进行查找软件,就是yum list | grep stl这行代码,测试如下方截图
ustl-devel.x86_64 2.8-1.el7 epel
如上方这行代码:软件包名称: 主版本号.次版本号.源程序发行号-软件包的发行号.主机平台.cpu架构."x86_64" 后缀表示64位系统的安装包, "i686" 后缀表示32位系统安装包. 选择包时要和系统匹配、"el7" 表示操作系统发行版的版本. "el7" 表示的是 centos7/redhat7. "el6" 表示 centos6/redhat6、最后一列, epel 表示的是 "软件源" 的名称, 类似于 "小米应用商店", "华为应用商店" 这样的概念.
2、install
通过 yum, 我们可以通过很简单的一条命令完成 gcc 的安装,yum 会自动找到都有哪些软件包需要下载, 这时候敲 "y" 确认安装,出现 "complete" 字样, 说明安装完成,如之前文章中安装tree的时候就是yum install -y tree就是下载树。
注意:
1、安装软件时由于需要向系统目录中写入内容, 一般需要 sudo 或者切到 root 账户下才能完成yum安装软件只能一个装完了再装另一个
2、 正在yum安装一个软件的过程中, 如果再尝试用yum安装另外一个软件, yum会报错,如果 yum 报错, 请自行百度,这里就不详细说了
如下方代码就是下载一个sl的开源应用,这个应用挺有意思是一个小火车跑过去,如下方视频
Linux小火车
3、remove
sudo yum remove就是删除应用的指令,这里就是把上面那个小火车的删除演示,如下方截图,删除后再用就没有了。
三、怎么创建仓库
这里就用国内的gitte进行演示了,如下方图片在浏览器内搜索gitte,这个就是官网,点进去注册登录,点击图二划红线的位置,然后如图三进行创建仓库然后点击创建。
如下方图一点击克隆然后如图二进行赋值第一个的https的链接,然后如下方代码所示,可以看到在进入test这个克隆的代码仓库就可以看出来在和gitte上面的仓库里面的东西一样,这就是克隆好了。
[ly1@VM-24-9-centos ~]$ ll
total 4
-rw-rw-r-- 1 ly1 ly1 462 Apr 11 20:03 test.c
[ly1@VM-24-9-centos ~]$ git clone https://gitee.com/three-thousand-luoshui/test.git
Cloning into 'test'...
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 6 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (6/6), done.
[ly1@VM-24-9-centos ~]$ ll
total 8
drwxrwxr-x 3 ly1 ly1 4096 Apr 12 20:45 test
-rw-rw-r-- 1 ly1 ly1 462 Apr 11 20:03 test.c
[ly1@VM-24-9-centos ~]$ ll -a
total 52
drwx------ 7 ly1 ly1 4096 Apr 12 20:45 .
drwxr-xr-x. 5 root root 4096 Apr 11 18:42 ..
-rw------- 1 ly1 ly1 1606 Apr 12 20:45 .bash_history
-rw-r--r-- 1 ly1 ly1 18 Apr 1 2020 .bash_logout
-rw-r--r-- 1 ly1 ly1 193 Apr 1 2020 .bash_profile
-rw-r--r-- 1 ly1 ly1 231 Apr 1 2020 .bashrc
drwxrwxr-x 3 ly1 ly1 4096 Apr 11 19:04 .cache
drwxrwxr-x 3 ly1 ly1 4096 Apr 11 19:04 .config
drwxrw---- 3 ly1 ly1 4096 Apr 12 20:45 .pki
drwxrwxr-x 3 ly1 ly1 4096 Apr 12 20:45 test
-rw-rw-r-- 1 ly1 ly1 462 Apr 11 20:03 test.c
drwxr-xr-x 2 ly1 ly1 4096 Apr 11 21:30 .vim
-rw------- 1 ly1 ly1 2615 Apr 11 21:30 .viminfo
[ly1@VM-24-9-centos ~]$ cd test
[ly1@VM-24-9-centos test]$ ll -a
total 28
drwxrwxr-x 3 ly1 ly1 4096 Apr 12 20:45 .
drwx------ 7 ly1 ly1 4096 Apr 12 20:45 ..
drwxrwxr-x 8 ly1 ly1 4096 Apr 12 20:45 .git
-rw-rw-r-- 1 ly1 ly1 270 Apr 12 20:45 .gitignore
-rw-rw-r-- 1 ly1 ly1 643 Apr 12 20:45 LICENSE
-rw-rw-r-- 1 ly1 ly1 841 Apr 12 20:45 README.en.md
-rw-rw-r-- 1 ly1 ly1 930 Apr 12 20:45 README.md
[ly1@VM-24-9-centos test]$
四、git三板斧
1、add
如下方代码所示,这里是创建了一个文件进行测试,测试的hello然后利用add提交,这是就会把这个文件提交到gitee上,也就相当于一个通知。
[ly1@VM-24-9-centos test]$ ll -a
total 28
drwxrwxr-x 3 ly1 ly1 4096 Apr 12 20:45 .
drwx------ 7 ly1 ly1 4096 Apr 12 20:45 ..
drwxrwxr-x 8 ly1 ly1 4096 Apr 12 20:45 .git
-rw-rw-r-- 1 ly1 ly1 270 Apr 12 20:45 .gitignore
-rw-rw-r-- 1 ly1 ly1 643 Apr 12 20:45 LICENSE
-rw-rw-r-- 1 ly1 ly1 841 Apr 12 20:45 README.en.md
-rw-rw-r-- 1 ly1 ly1 930 Apr 12 20:45 README.md
[ly1@VM-24-9-centos test]$ vim test.c
[ly1@VM-24-9-centos test]$ gcc -o hello test.c
[ly1@VM-24-9-centos test]$ ll
total 28
-rwxrwxr-x 1 ly1 ly1 8360 Apr 12 20:49 hello
-rw-rw-r-- 1 ly1 ly1 643 Apr 12 20:45 LICENSE
-rw-rw-r-- 1 ly1 ly1 841 Apr 12 20:45 README.en.md
-rw-rw-r-- 1 ly1 ly1 930 Apr 12 20:45 README.md
-rw-rw-r-- 1 ly1 ly1 70 Apr 12 20:48 test.c
[ly1@VM-24-9-centos test]$ ./hello
Hello Word
[ly1@VM-24-9-centos test]$ git add test.c
[ly1@VM-24-9-centos test]$
2、commit
如下方带吗,我直接提交显示的是请告诉我你是谁,也就是他不知道我是谁,下面还给了两个代码,大概意思就是让我们用这个去更改邮箱和用户名,就是引号里面的,用户名就是个人主页这个@后面的,邮箱是自己填的。
[ly1@VM-24-9-centos test]$ git commit .*** Please tell me who you are.Rungit config --global user.email "you@example.com"git config --global user.name "Your Name"to set your account's default identity.
Omit --global to set the identity only in this repository.fatal: empty ident name (for <ly1@VM-24-9-centos.(none)>) not allowed
[ly1@VM-24-9-centos test]$
然后在进行提交这两行代码,然后在进行提交就会出现下方第二个代码,这是说我在提交的时候没有进行备注说明,也就是下方第一个代码块第三句代码,.就是全部提交。
[ly1@VM-24-9-centos test]$ git config --global user.email "2552696329@qq.com"
[ly1@VM-24-9-centos test]$ git config --global user.name "three-thousand-luoshui"[ly1@VM-24-9-centos test]$ git commit .
Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# Explicit paths specified without -i nor -o; assuming --only paths...
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: test.c
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# hello
这是如下方代码这样在git commit .后面加上-m然后引号,在引号内加上自己的提交信息,就提交上去了。
[ly1@VM-24-9-centos test]$ git commit . -m"这是一个测试"
[master 8d8920e] 这是一个测试
2 files changed, 6 insertions(+)
create mode 100755 hello
create mode 100644 test.c
[ly1@VM-24-9-centos test]$
3、push
这是就需要push推送到gitee上的仓库,让两个仓库内容相同,如下方代码,就可以看到gitee上的仓库也提交成功了。
[ly1@VM-24-9-centos test]$ git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:git config --global push.default matchingTo squelch this message and adopt the new behavior now, use:git config --global push.default simpleSee 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)Username for 'https://gitee.com': 17719362786
Password for 'https://17719362786@gitee.com':
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 2.65 KiB | 0 bytes/s, done.
Total 4 (delta 1), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-6.4]
To https://gitee.com/three-thousand-luoshui/test.gite4ecb6d..8d8920e master -> master
[ly1@VM-24-9-centos test]$
4、pull
这个就是拉取,如上方代码在我有创建了一个文件进行测试,但是这次提交却不成功,这是因为啥?看他的报错意思就是两边代码不同步,这是就需要利用pull进行拉取同步。
[ly1@VM-24-9-centos test]$ vim test3.c
[ly1@VM-24-9-centos test]$ ll
total 28
-rwxrwxr-x 1 ly1 ly1 8360 Apr 12 20:49 hello
-rw-rw-r-- 1 ly1 ly1 643 Apr 12 20:45 LICENSE
-rw-rw-r-- 1 ly1 ly1 841 Apr 12 20:45 README.en.md
-rw-rw-r-- 1 ly1 ly1 930 Apr 12 20:45 README.md
-rw-rw-r-- 1 ly1 ly1 0 Apr 12 21:20 test3.c
-rw-rw-r-- 1 ly1 ly1 70 Apr 12 20:48 test.c
[ly1@VM-24-9-centos test]$ git add.
git: 'add.' is not a git command. See 'git --help'.Did you mean this?add
[ly1@VM-24-9-centos test]$ git add .
[ly1@VM-24-9-centos test]$ git commit . -m"test"
[master cf21b89] test1 file changed, 0 insertions(+), 0 deletions(-)create mode 100644 test3.c
[ly1@VM-24-9-centos test]$ git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:git config --global push.default matchingTo squelch this message and adopt the new behavior now, use:git config --global push.default simpleSee 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)Username for 'https://gitee.com': 17719362786
Password for 'https://17719362786@gitee.com':
To https://gitee.com/three-thousand-luoshui/test.git! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://gitee.com/three-thousand-luoshui/test.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first merge the remote changes (e.g.,
hint: 'git pull') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
[ly1@VM-24-9-centos test]$
如下方代码就是先利用pull进行拉取让两边代码仓库同步,然后进行提交就可以了,如下方图片。
[ly1@VM-24-9-centos test]$ git pull
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From https://gitee.com/three-thousand-luoshui/test8d8920e..3c04c04 master -> origin/master
Merge made by the 'recursive' strategy.test2 | 01 file changed, 0 insertions(+), 0 deletions(-)create mode 100644 test2
[ly1@VM-24-9-centos test]$ ll
total 28
-rwxrwxr-x 1 ly1 ly1 8360 Apr 12 20:49 hello
-rw-rw-r-- 1 ly1 ly1 643 Apr 12 20:45 LICENSE
-rw-rw-r-- 1 ly1 ly1 841 Apr 12 20:45 README.en.md
-rw-rw-r-- 1 ly1 ly1 930 Apr 12 20:45 README.md
-rw-rw-r-- 1 ly1 ly1 0 Apr 12 21:23 test2
-rw-rw-r-- 1 ly1 ly1 0 Apr 12 21:20 test3.c
-rw-rw-r-- 1 ly1 ly1 70 Apr 12 20:48 test.c
[ly1@VM-24-9-centos test]$ git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:git config --global push.default matchingTo squelch this message and adopt the new behavior now, use:git config --global push.default simpleSee 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)Username for 'https://gitee.com': 17719362786
Password for 'https://17719362786@gitee.com':
Counting objects: 6, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 501 bytes | 0 bytes/s, done.
Total 4 (delta 2), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-6.4]
To https://gitee.com/three-thousand-luoshui/test.git3c04c04..8160868 master -> master
[ly1@VM-24-9-centos test]$