Git命令简略应用

背景

最近常常应用Github,每次批改个文件代码都要在网页端操作,感觉效率低下,所以简答学习理解了一下Git命令。至使于能够在命令行进行治理Git仓库,这样就不须要每次都要关上网页版Github进行操作。

常用命令应用

# 拉取服务器代码,更新本地代码,防止笼罩别人代码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 statusOn branch mainYour branch is up to date with 'origin/main'.Changes to be committed:  (use "git restore --staged <file>..." to unstage)    modified:   README.mdroot@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 pushUsername for 'https://github.com': cby-chenPassword for 'https://cby-chen@github.com': Enumerating objects: 5, done.Counting objects: 100% (5/5), done.Delta compression using up to 8 threadsCompressing 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 0remote: Resolving deltas: 100% (2/2), completed with 2 local objects.To https://github.com/cby-chen/Kubernetes.git   a101d22..260d794  main -> mainroot@hello:~/Kubernetes# 

留神

  1. 在push的时候是须要输出token,这个token须要在:https://github.com/settings/t... 进行创立
  2. GitHub的README.md文件内容换行,间接在要换行的语句最初打上2个空格。
  3. 如果你感觉 git add 提交缓存的流程太过繁琐,Git 也容许你用 -a 选项跳过这一步。命令格局如下: git commit -a

对于

https://www.oiox.cn/

https://www.oiox.cn/index.php...

CSDN、GitHub、知乎、微信公众号、开源中国、思否、掘金、简书、华为云、阿里云、腾讯云、哔哩哔哩、今日头条、新浪微博、集体博客、全网可搜《小陈运维》

文章次要公布于微信公众号