# 拉取服务器代码,更新本地代码,避免覆盖他人代码 root@hello:~/Kubernetes# git pull Already up to date. root@hello:~/Kubernetes# # 修改文件 root@hello:~/Kubernetes# vim README.md # 将状态改变的代码提交至缓存 root@hello:~/Kubernetes# git add . # 查看当前项目中有哪些文件被修改过 root@hello:~/Kubernetes# git status On branch main Your branch is up to date with 'origin/main'.
Changes to be committed: (use "git restore --staged <file>..." to unstage) modified: README.md
root@hello:~/Kubernetes# # 将代码提交到本地仓库中 root@hello:~/Kubernetes# git commit -m update [main 260d794] update 1 file changed, 25 insertions(+), 25 deletions(-) root@hello:~/Kubernetes# # 将缓存区代码推送到远程仓库 root@hello:~/Kubernetes# git push Username for 'https://github.com': cby-chen Password for 'https://cby-chen@github.com': Enumerating objects: 5, done. Counting objects: 100% (5/5), done. Delta compression using up to 8 threads Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 434 bytes | 434.00 KiB/s, done. Total 3 (delta 2), reused 0 (delta 0), pack-reused 0 remote: Resolving deltas: 100% (2/2), completed with 2 local objects. To https://github.com/cby-chen/Kubernetes.git a101d22..260d794 main -> main root@hello:~/Kubernetes#