CICD 持续集成与持续交付——git

git使用

[root@cicd1 ~]# yum install -y git

[root@cicd1 ~]# mkdir demo

[root@cicd1 ~]# cd demo/

初始化版本库

[root@cicd1 demo]# git init

查看状态

[root@cicd1 demo]# git status

[root@cicd1 demo]# git status  -s #简化输出

[root@cicd1 demo]# echo test > README.md

[root@cicd1 demo]# ls

[root@cicd1 demo]# git status -s

[root@cicd1 demo]# git add README.md

[root@cicd1 demo]# git status  -s

[root@cicd1 demo]# git config --global user.email "924023742@qq.com"

[root@cicd1 demo]# git config --global user.name "hjl"

[root@cicd1 demo]# git commit -m "add README.md"

[root@cicd1 demo]# echo hello >> README.md

[root@cicd1 demo]# git status -s

[root@cicd1 demo]# git add README.md

[root@cicd1 demo]# git status -s

[root@cicd1 demo]# echo world >> README.md

[root@cicd1 demo]# git status -s


 

[root@cicd1 demo]# git commit -m "v1"

[root@cicd1 demo]# git status -s

[root@cicd1 demo]# git add .

[root@cicd1 demo]# git status -s

[root@cicd1 demo]# git commit -m "v2"

[root@cicd1 demo]# git status -s

忽略隐藏文件

[root@cicd1 demo]# touch .a

[root@cicd1 demo]# git status -s

[root@cicd1 demo]# vim .gitignore

[root@cicd1 demo]# git status -s

[root@cicd1 demo]# echo helloworld > test.txt

[root@cicd1 demo]# git add test.txt

[root@cicd1 demo]# git commit -m "add test.txt"

撤销文件修改

[root@cicd1 demo]# rm -f test.txt

[root@cicd1 demo]# git status -s

[root@cicd1 demo]# git checkout -- test.txt

取消暂存区文件

[root@cicd1 demo]# git rm test.txt

[root@cicd1 demo]# git status  -s

[root@cicd1 demo]# git reset HEAD test.txt

版本回退

[root@cicd1 demo]# git rm test.txt

[root@cicd1 demo]# git commit -m "delete test.txt"

[root@cicd1 demo]# git reflog

[root@cicd1 demo]# git reset --hard 110c7e6

github远程代码仓库

登录:https://github.com/

上传公钥

[root@cicd1 ~]# ssh-keygen

[root@cicd1 ~]# cat .ssh/id_rsa.pub

推送仓库

[root@cicd1 ~]# cd demo/

[root@cicd1 demo]# git branch -M main

[root@cicd1 demo]# git remote add origin git@github.com:he-bao/demo.git

[root@cicd1 demo]# git remote -v

[root@cicd1 demo]# git push -u origin main

克隆仓库

[root@cicd1 ~]# rm -fr demo/

[root@cicd1 ~]# git clone git@github.com:he-bao/demo.git

[root@cicd1 ~]# cd demo/

[root@cicd1 demo]# ls

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值