赞
踩
Git作用:git的作用就是对文件进行版本管理,方便在不同版本进行切换修改
Git特点:
自诞生于 2005 年以来,Git 日臻成熟完善,在高度易用的同时,仍然保留着初期设定的目标。 它的速度飞快,极其适合管理大项目,有着令人难以置信的非线性分支管理系统。
Git必看秘籍:https://git-scm.com/book/zh/v2
安装Git
- # yum install -y git
- # mkdir demo
- # cd demo
- # git init 版本初始化
- # git config --global user.email "yueyue@cc.com" 新建用户邮件
- # git config --global user.name "yueyue" 新建用户名
- # git status -s
- # git status 查看状态
- # git add README 添加到暂存区
- # git checkout -- README 撤销对文件的修改
- # git commit 提交更新
练习:
提交:
- # touch README
- # echo westos > README 写入内容
- # git status -s
- # git add README 添加
- # git status -s
- # git commit -m "v1" 提交缓存区的内容
- # git log 查看提交历史
# git commit -a -m 'added new benchmarks' 跳过缓存区提交
删除:
- [root@localhost demo]# git rm FILE
- [root@localhost demo]# git commit -m v4
撤销:
- [root@localhost demo]# echo haha >> westos
- [root@localhost demo]# git checkout -- "westos" 撤销
注册github帐号,并新建一个仓库(http://www.gittub.com或者 http://gitee.com)
在虚拟机中生成秘钥,并复制
# ssh-keygen
免密成功
- [root@localhost demo]# git remote add origin git@github.com:byueyue/demo.git (选择ssh,如果选择了https就不可以在添加ssh了可以执行 # git remote rm origin)
- # git remote -v
- [root@localhost demo]# git push -u origin master
测试:将本地目录删除后,可以从远程仓库克隆下载
# git clone git@github.com:byueyue/demo.git
官网:https://about.gitlab.com/install/
软件下载(官方下载慢,推荐使用国内镜像站点)
https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/
软件安装: (官方推荐至少4G内存)
- # yum install -y curl policycoreutils-python openssh-server
- # rpm -ivh gitlab-ce-12.9.7-ce.0.el7.x86_64.rpm
修改配置文件
- # vim /etc/gitlab/gitlab.rb 修改完必须重新加载文件
- # gitlab-ctl gitlab-ctl reconfigure 重新加载
# gitlab-ctl status 查看状态
登录gitlab:
http://172.25.0.11 //用户:root 第一次登录需要强制修改密码
添加ssh免密
添加项目
使用ssh克隆
# git clone git@172.25.254.6:root/demo.git (注意seliunx和防火墙状态)
- # touch index.html
- # git add index.html
- # git -m "add index.html" 添加到缓存
- # git commit -m "add index.html" 跟新
- # git push -u origin master 上传
查看:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。