在項目中常用的git命令

git 常用命令

// 本地與遠(yuǎn)程分支記錄同步
git remote prune origin
//新建分支
git branch xxx
//新建遠(yuǎn)程分支  
git push origin xxx:xxx
// 切換分支
git checkout xxx  
//刪除遠(yuǎn)程某個分支
git push origin branch —delete xxx
// 刪除遠(yuǎn)程某個分支
git push origin :branchname
//查看本地分支
git branch
//查看本地和遠(yuǎn)程分支
git branch -a 
//查看已修改文件
git status  
// 提交到緩存
git add .
// 完成提交  
git commit -m 'string'
//合并到這個hash值
git rebase -i hash 
// 清理本地緩存
git clean -df 

完成自己的開發(fā)后

//  查看自己修改的文件
$ git status
// 提交到緩存(add . 全部提交)
$ git add .
// 正式提交commit
$ git commit -m ‘輸入提交信息’
// 切到dev 
$ git checkout develop
// 同步log信息
$ git fetch
// 同步dev分支 -  - rebase 有兩個-
$ git pull —rebase
// 切回wenjun/task1 分支
$ git checkout wenjun/task1
// rebase   dev
$ git rebase develop
// 切回dev
$ git checkout develop
// dev rebase 我的分支
$ git rebase wenjun/task1
// 推送dev分支到gitlab
$ git push

git回滾到某個版本

* git  reset —hard dasd54895612d8as65d1   // commit 的hash值

新建git本地倉庫

git config —global user.name ‘wenjun’  // 設(shè)置git 用戶名
git config —global user.email ‘liwenjunas@126.com’  // 設(shè)置gitemail郵箱
ssh-keygen -t rsa -C liwenjunas@126.com    ///  生成ssh加密秘鑰
git config —list  //查看配置信息
Pwd  // 查看當(dāng)前路徑 [linux可用]
Git init //初始化本地倉庫

合并log

$ git rebase -i commit Hash //i 編輯   esc 退出 :wq保存

Git緊急修復(fù)tag某個版本出的問題

  • git checkout -b hotFixBranchName v2.0
  • // 基于tag v2.0 切出來一個分支(hotFixBranchName)
  • git rebase hotFixBranchName
  • //用develop rebase hotFixBranchName
  • 使用dev rebase hotFixBranchName
  • 然后基于 這個commit 的 ID 打一個 TAG
  • git tag -a v2.xx commitHash
  • 然后 git push -f 強推 清空遠(yuǎn)程分支 推上本地分支
  • git push —tags 把本地所有tags 推送到遠(yuǎn)程分支上
  • 最后基于這個hotfix的tag 切出來一個新分支 進行發(fā)布
  • 刪除遠(yuǎn)程tag git push origin :v1.1
  • 刪除遠(yuǎn)程tag2 git push origin — delete v1.1
  • 刪除本地tag git tag -d v1.1
  • 同步遠(yuǎn)程tag git

已有項目同步git

git remote add origin https://gitee.com/hotmail.oschina.net/PDF.git
git push -u origin master

其他非git

  • 修改代理ip調(diào)試上傳功能

  • 需修改文件host

  • 位置

    • 打開file 前往/private文件夾
    • 進入etc 然后修改host
  • 鏈接服務(wù)器后執(zhí)行自動命令

    cd /home/app/jpbm/ && git branch && git checkout develop && git fetch && git pull --rebase && git log
    
  • Mac強刷瀏覽器

    command + shift + R
    
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容