当前位置:首页 > 编程笔记 > 正文
已解决

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

来自网友在路上 176876提问 提问时间:2023-11-21 01:21:25阅读次数: 76

最佳答案 问答题库768位专家为你答疑解惑

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

查看全文

99%的人还看了

猜你感兴趣

版权申明

本文"CICD 持续集成与持续交付——git":http://eshow365.cn/6-40770-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!