日常總結 -- gitlab篇

常用命令

  1. clone :-----git clone http://127.0.0.1/surliya/gittest.git

  2. add: 注意不要什麼都提交.gitignore
    git config --global user.namesurliya
    git config --global user.email “[email protected]
    cd gittest
    git init
    git remote add origin http://127.0.0.1/surliya/gittest.git
    git add .
    git commit -m"init"
    git push -u origin master

  3. commit: 規範Message ------commit -m"update"

  4. push : ------ git push -u origin master

  5. pull(作用是:取回遠程主機某個分支的更新,再與本地的指定分支合併)
    ---------git pull [遠程主機名] <遠程分支名>:<本地分支名>
    git pull origin next:master
    git pull origin next(遠程分支next要與當前分支合併)
    ==>git fetch origin next:master(獲取)
    -> git diff next(查看)
    -> git merge next(合併)
    (更安全,可以在merge前,查看跟新情況,再決定是否合併)

  6. branch(git clone 時,本地master分支自動"追蹤"origin/master分支)
    git branch --set-upstream master origin/next(手動建立追蹤關係)

  7. checkout(開啓分支並切換): git fetch origin 分支,git checkout -b 分支 origin/分支 /* git checkout origin/分支 */
    git checkout [-b] testbranch ==> git branch testbranch
    git add -A(提交修改到暫存區)
    git commit -m “testbranch”(帶註釋提交)
    git push origin testbranch(發佈到gitlab上)
    git checkout master (切換到master分支)
    //git checkout master -> git pull origin master -> git merge dev
    git rm -r --cached . // 清除本地緩存

  8. reset(文件從暫存區回退到工作區):
    git reset HEAD readme.txt(回退文件)
    git reset HEAD^(回退上個版本)
    git commit --amend(追加提交)
    git reset --help (查看幫助)

  9. 衝突處理: 如何發現衝突; git merge testbranch (合併時發現衝突)
    如何看衝突文件; git status -> git diff readme.txt
    如何處理衝突文件; git add readme.txt -> git status -> git commit -m"update"

  10. 將依賴加入本地 maven 庫(以sapjco3爲例)
    mvn install:install-file -DgroupId=org.hibersap -DartifactId=sapjco3 -Dversion=3.0 -Dpackaging=jar -Dfile=E:/sapjco3/sapjco3.jar

其它總結

  1. 協議: https://git-scm.com/book/zh/v2/服務器上的-Git-協議
  2. Git 提示fatal: remote origin already exists 錯誤解決辦法: https://blog.csdn.net/top_code/article/details/50381432
  3. gitLab本地推送到遠程倉庫的命令: https://www.cnblogs.com/caiyineng/p/6636693.html
  4. git 文件添加、變更的提交: https://blog.csdn.net/dazhi_100/article/details/38851733
  5. 解決衝突: https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/001375840202368c74be33fbd884e71b570f2cc3c0d1dcf000 ;
    https://www.cnblogs.com/xiaoerlang/p/3810206.html ;
    https://blog.csdn.net/zwl18210851801/article/details/79106448
  6. web hook設置: https://blog.csdn.net/weiguang1017/article/details/78594507
  7. Access denied: https://blog.csdn.net/xiatianyangwang/article/details/78652313
  8. “Please make sure you have the correct access rights and the repository exists.”問題: https://blog.csdn.net/jingtingfengguo/article/details/51892864
  9. ssh與https互換: https://blog.csdn.net/yym836659673/article/details/77504430
  10. git 將項目遷移到另一個倉庫: https://blog.csdn.net/zzzgd_666/article/details/81252470
  11. git忽略規則以及.gitignore文件不生效解決辦法: https://www.jianshu.com/p/60281010a215
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章