CI/CD 持续集成与持续交付(1)

git

Git

CI/CD 持续集成与持续交付(1)_第1张图片

git使用

[root@server1 ~]# yum install -y git
[root@server1 ~]# mkdir demo
[root@server1 ~]# cd demo/

初始化版本库

[root@server1 demo]# git init

CI/CD 持续集成与持续交付(1)_第2张图片

查看状态

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

CI/CD 持续集成与持续交付(1)_第3张图片

[root@server1 demo]# echo test > README.md
[root@server1 demo]# ls
[root@server1 demo]# git status  -s
?? README.md

CI/CD 持续集成与持续交付(1)_第4张图片

[root@server1 demo]# git add README.md
[root@server1 demo]# git status  -s
A  README.md

[root@server1 demo]# git config --global user.email "[email protected]"
[root@server1 demo]# git config --global user.name "shx"
[root@server1 demo]# git commit -m "add README.md"

CI/CD 持续集成与持续交付(1)_第5张图片

 


[root@server1 demo]# echo hello >> README.md
[root@server1 demo]# git status -s
 M README.md

[root@server1 demo]# git add README.md
[root@server1 demo]# git status -s
M  README.md

[root@server1 demo]# echo world >> README.md
[root@server1 demo]# git status -s
MM README.md

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

[root@server1 demo]# git status -s
 M README.md

[root@server1 demo]# git add .
[root@server1 demo]# git status -s
M  README.md

[root@server1 demo]# git commit -m "v2"
[root@server1 demo]# git status -s

CI/CD 持续集成与持续交付(1)_第6张图片

忽略隐藏文件

[root@server1 demo]# touch .a
[root@server1 demo]# git status -s
?? .a
[root@server1 demo]# vim .gitignore
.*
[root@server1 demo]# git status -s
CI/CD 持续集成与持续交付(1)_第7张图片

撤销文件修改

[root@server1 demo]# echo helloworld > test.txt
[root@server1 demo]# git add test.txt
[root@server1 demo]# git commit -m "add test.txt"
[root@server1 demo]# rm -f test.txt
[root@server1 demo]# git status -s
 D test.txt
[root@server1 demo]# git checkout -- test.txt

CI/CD 持续集成与持续交付(1)_第8张图片

取消暂存区文件

[root@server1 demo]# git rm test.txt
[root@server1 demo]# git status  -s
D  test.txt
[root@server1 demo]# git reset HEAD test.txt

CI/CD 持续集成与持续交付(1)_第9张图片

版本回退

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

[root@server1 demo]# git reflog
[root@server1 demo]# git reset --hard 6823e45

CI/CD 持续集成与持续交付(1)_第10张图片

github远程代码仓库

登录:GitHub: Let’s build from here · GitHub

 创建一个新仓库

CI/CD 持续集成与持续交付(1)_第11张图片 

上传公钥

 CI/CD 持续集成与持续交付(1)_第12张图片

推送仓库

CI/CD 持续集成与持续交付(1)_第13张图片

[root@server1 ~]# cd demo/
[root@server1 demo]# git branch -M main
[root@server1 demo]# git remote add origin https://github.com/suhongxing/demo.git
[root@server1 demo]# git remote -v
origin  https://github.com/suhongxing/demo.git (fetch)
origin  https://github.com/suhongxing/demo.git (push)

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

CI/CD 持续集成与持续交付(1)_第14张图片

 CI/CD 持续集成与持续交付(1)_第15张图片

 克隆仓库

[root@server1 ~]# rm -fr demo/
[root@server1 ~]# git clone [email protected]:su-hongxing/demo.git

CI/CD 持续集成与持续交付(1)_第16张图片

你可能感兴趣的:(ci/cd)