日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

工作中常用命令(git和k8s)

發布時間:2024/1/18 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 工作中常用命令(git和k8s) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

GIT

在本地分支.上開發

  • 創建本地分支
  • 現切換到master
  • git checkout master git pull
  • 建議使用單獨的本地分支進行開發,可以用一下命令從當前分支創建一個本地分支。
  • git checkout -b <branch_name>
  • 如果最終這個分支上的代碼提交到遠程分支上,為了防止分支名稱沖突,建議使用自己的ldap作為前綴,比如pc- add- some-codes
  • 提交本地修改
  • Git 每次提交前需要把準備提交的文件添加到索引(Index)里面,可以使用git add 添加索引。
  • #添加所有修改過的文件和所有新文件 git add .
  • 提交前可以使用git status 看當前工作目錄的狀態,也可以使用git diff查看具體修改內容,確認無誤之后用一下命令提交。
  • git commit -m' commit msg '
  • 代碼格式檢查
  • /Users/huangjialin/ .yc-scr ipts/ gi t-hooks/.. /git-fix. sh
  • 查看本地分支
  • git branch

    向GitLab提交代碼

  • git push 可以將本地分支到GitLab。 建議遠程分支和本地分支使用同樣的名字,如果遠程分支不存在,GitLab會自動創建。
  • git push origin HEAD: <remote_ branch_ name>#例如 #git@gi tlab. yaochn. com: infra/mixer.git git push origin HEAD: infra/mixer.git~/ business-directory jialin-alter-RoleType-code > git push origin HEAD:jialin-alter-RoleType-code
  • 注意,不要使用git commit --amend或者git rebase 修改已經推送到遠程的提交或者分支,否則會導致后續的推送失敗。
  • 可以設置git默認將本地分支推送到遠程同名分支,這樣在每次推送時省略refspec參數。
  • git config --global push.default current

    分支獲取最新代碼

    git fetchgit merge origin/mastergit push origin HEAD: huangjialin-alter-some-codes

    強制拉取并覆蓋本地代碼

    git fetch --allgit reset --hard origin/ mastergit pull

    git pull 和 git fetch的區別?

    https://www.zhihu.com/question/38305012

    master獲取最新代碼

    git checkout master git pull

    沖突解決

  • 如果在運行git merge 時提示有沖突,那么就需要手動編輯有沖突的
  • 文件。VSCode, IntelliJ都可以輔助解決合并沖突。沖突文件手工合并后, 需要用git add 標記沖突已解決,然后用以下命令繼續完成合并。
  • git merge --continue

    有時testing項目會拒絕commit,如果確定自己的代碼格式沒有問題,則可以選擇使用以下命令進行強制提交

    git commit -m "提交信息" -n

    本地分?push到遠程master時可能會出現落后遠程分?拒絕push的提?,則可以嘗試以下命令進? 強制提交

    git push origin HEAD:<remote_branch_name> -f

    遠程代碼合并操作匯總

    ~/business-directory jialin-check-function > git checkout master ... ~/business-directory master > git pull ... ~/business-directory master > git checkout jialin-check-function .... ~/business-directory jialin-check-function > git merge origin/master ... ~/business-directory jialin-check-function > git status 4s py infra_test:infra_test 3.8.7 16:43:04 位于分? jialin-check-function ??件要提交,?凈的?作區 ~/business-directory jialin-check-function > git merge origin/master py infra_test:infra_test 3.8.7 16:43:10 已經是最新的。

    進?以上操作即可完成本地分?與遠程分?的合并

    git 回退到某個commit

    git log -3 #查看最新提交的三個版本號 git reset --hard HEAD^ #回退到上個版本 git reset --hard HEAD~3 #回退到前3次提交之前,以此類推,回退到n次提交之前 git reset --hard commit_id #退到/進到指定commi t的sha碼

    強制清空本地commit

    git stash git stash clear

    選擇stash

    第?次stash:

    > git stash

    查詢stash 列表:

    > git stash list > stash@{0}: WIP on fixResponseType: 8ba2b28 add and change some logic 12

    第?次stash:

    > git stash

    查詢stash 列表:

    > git stash list stash@{0}: WIP on emcache: c13f985 Merge pull request #12 from username/fixRespo nseType stash@{1}: WIP on fixResponseType: 8ba2b28 add and change some logic

    可以看到 stash@{0} 是最新的緩存,stash@{1} 是第?次的stash,所以選擇指定的緩存恢復的操作如 下:

    > git stash pop stash@{1}

    這個是恢復第?次的緩存

    測試文件更新

    在對應的api修改之后,如果進行測試需要更新其相應的測試文件
    即在對應的分支下執行

    pip install -U -r requirements.txt ~/testing jialin-refactor-roleCode +3 > pip install -U -r requirements. txt

    K8S

    重啟k8s

  • 銷毀本地部署
  • kubecfg delete local/deployment.jsonnet
  • 查看所有都pods被關閉
  • kubectl get pods
  • 重新部署
  • cd deployment kubecfg update local/deployment.jsonnet
  • 檢查所有pods均被啟動
  • kubectl get pods
  • 開啟nginx
  • kubectl port- forward service/nginx 9443: 443 kubectl port- forward service/nginx 8443: 443 kubectl port- forward service/nginx 8080: 80

    開啟成功后可訪問
    https://local.develop.yaochn.com:8443/ https://local.develop.yaochn.com:9443/
    此?法會清空本地數據庫

    查看log?志

    kubectl logs service/ auth-hub #查看對應項目的的log kubectl describe pod notificati on-77464c574-49bc7 #查看具體pod描述

    異常監控

    jenkins.yaochn.com https://jenkins.yaochn.com/

    總結

    以上是生活随笔為你收集整理的工作中常用命令(git和k8s)的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。