本地仓库初始操作
-------------------- 本地git仓库第一次使用-------------------
---------- .gitignore也放进去 ---------
set i=kc-chat&&set j=atdemo
------------ 已有本地提交 ---------------
git rm -r --cached . -f && git add . && git commit -m "chore: refresh git cache and apply .gitignore" && git remote remove origin
---------------本地无------------------
set i=kc-tools-ppt&&git init && git add . && git commit -m "chore: refresh git cache and apply .gitignore" && git branch -M master && git remote remove origin
git remote add origin git@%j%.git.atibm.com:%j%/%i%.git && git push --all origin通过opencode梳理形成git分支树
背景
远端 main 分支混入了 hermes 的 8 次提交(105389b~995d77a),本地还有 opencode 未完成的 scripts/***** 改动,以及从其他项目移入的路演报告设计、RR脚本分析、日程安排等文件。需要重新梳理 git 分支树,分离不同归属的代码。
最终分支结构
main (回退到 dd71007 + 新增路演/RR/日程)
│
└── hermes-stdd (888a2af ~ 995d77a,18 次 hermes 提交)
│
└── opencode (hermes-stdd + opencode 完成的 *** 脚本)| 分支 | 包含提交 | 说明 |
|---|---|---|
main | dd71007(base) + 928bbb3(路演/RR/日程) | 远端(force push) + 本地 |
hermes-stdd | 888a2af ~ 995d77a (18 次) | 远端新建 + 本地 |
opencode | hermes-stdd + c101470(*** 脚本) | 远端 + 本地 |
操作步骤
git checkout -b temp-save; git add -A; git commit -m "temp"— 保存全部工作区git branch hermes-stdd origin/main— hermes-stdd 指向远端 hermes 提交git checkout main; git reset --hard dd71007— main 回退到 basegit checkout temp-save -- 路演/RR/日程; git commit -m "feat: add..."— main 保留新文件git checkout -b opencode hermes-stdd— opencode 从 hermes-stdd 分叉git rm -rf scripts/****/; git checkout temp-save -- scripts/***/; git commit -m "feat: opencode..."— opencode 完成 *** 脚本git branch -D temp-save— 清理临时分支git push -f origin main; git push origin hermes-stdd; git push origin opencode— 推送远端