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

git使用

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

[root@cicd1 ~]# mkdir demo

[root@cicd1 ~]# cd demo/

初始化版本库

[root@cicd1 demo]# git init

CICD 持续集成与持续交付——git_第1张图片

CICD 持续集成与持续交付——git_第2张图片

查看状态

[root@cicd1 demo]# git status

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

CICD 持续集成与持续交付——git_第3张图片

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

[root@cicd1 demo]# ls

[root@cicd1 demo]# git status -s

CICD 持续集成与持续交付——git_第4张图片

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

[root@cicd1 demo]# git status  -s

CICD 持续集成与持续交付——git_第5张图片

[root@cicd1 demo]# git config --global user.email "[email protected]"

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

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

CICD 持续集成与持续交付——git_第6张图片

[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

CICD 持续集成与持续交付——git_第7张图片

[root@cicd1 demo]# git add .

[root@cicd1 demo]# git status -s

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

[root@cicd1 demo]# git status -s

CICD 持续集成与持续交付——git_第8张图片

忽略隐藏文件

[root@cicd1 demo]# touch .a

[root@cicd1 demo]# git status -s

[root@cicd1 demo]# vim .gitignore

CICD 持续集成与持续交付——git_第9张图片

[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

CICD 持续集成与持续交付——git_第10张图片

取消暂存区文件

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

[root@cicd1 demo]# git status  -s

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

CICD 持续集成与持续交付——git_第11张图片

版本回退

[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

CICD 持续集成与持续交付——git_第12张图片

github远程代码仓库

登录:https://github.com/

CICD 持续集成与持续交付——git_第13张图片

上传公钥

[root@cicd1 ~]# ssh-keygen

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

CICD 持续集成与持续交付——git_第14张图片

CICD 持续集成与持续交付——git_第15张图片

CICD 持续集成与持续交付——git_第16张图片

CICD 持续集成与持续交付——git_第17张图片

推送仓库

[root@cicd1 ~]# cd demo/

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

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

[root@cicd1 demo]# git remote -v

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

CICD 持续集成与持续交付——git_第18张图片

CICD 持续集成与持续交付——git_第19张图片

克隆仓库

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

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

[root@cicd1 ~]# cd demo/

[root@cicd1 demo]# ls

CICD 持续集成与持续交付——git_第20张图片

你可能感兴趣的:(CICD,ci/cd,git,elasticsearch)