5 个不稳定版本
0.3.1 | 2023年8月21日 |
---|---|
0.3.0 | 2022年12月9日 |
0.2.2 | 2022年9月27日 |
0.1.2 | 2022年6月9日 |
0.0.8 |
|
在 开发工具 中排名第 143
每月下载量 31 次
31KB
624 行(不包括注释)
stc
(工作进行中;非常实验性)
简化堆叠功能分支的 git 变基
目标用户
stc 适用于以下工作流程:
- 个人贡献者在同一仓库中工作,
- 向从主分支或主题分支分叉的 dev 分支提交,
- 每个 dev 分支完全由一个贡献者所有和使用,
- 并期望贡献者提供干净的提交历史(不带合并)以供审查。
stc 有助于管理整个 堆叠 的这些 dev 分支,即当它们相互分支并依赖时,从而实现更快的开发。当某个分支正在进行审查时,另一个分支可以堆叠到它上面并工作。
工作流程
-
创建一个新的分支。
stc start my-new-feature
-
进行一些工作。
git add ...
.git commit ...
. 重复。 -
同时,基础分支有其他贡献者的合并。获取所有内容。
stc sync
-
变基分支,使其从基础分支的头部分叉。
stc rebase
-
通过首次推送发布分支。
stc push
-
哦,有一个坏的提交。
gitrebase -iHEAD~5
-
现在本地分支和远程分支分叉了。再次推送(强制)将远程分支设置为本地分支所指向的内容。
stc push
安装
需要安装 Rust 工具链。
cargo install stc
cargo install --git https://github.com/cloneable/stc
用法
stc 0.1.0
[WIP] Easy stacking of dev branches in git repositories.
USAGE:
stc <SUBCOMMAND>
OPTIONS:
-h, --help Print help information
-V, --version Print version information
SUBCOMMANDS:
clean Cleans any stc related refs and settings from repo.
fix Adds, updates and deletes tracking refs if needed.
help Print this message or the help of the given subcommand(s)
init Initializes the repo and tries to set stc refs for any non-default branches.
push Sets remote branch head to what local branch head points to.
rebase Rebases current branch on top of its base branch.
start Starts a new branch off of current branch.
sync Fetches all branches and tags and prunes deleted ones.
内部原理
跟踪引用
Stc 使用自定义引用来跟踪分支
-
引用/stc/base/<branchname>
到堆叠中父分支的符号引用。创建分支时创建。只有在分支在堆叠中移动时才更新。删除分支时删除。
-
引用/stc/开始/<branchname>
分支开始的提交。在创建分支时创建。在rebase后更新。在删除分支时删除。
-
引用/stc/远程/<branchname>
期望远程分支头所在的提交。在第一次推送分支时创建。在推送后更新。在删除分支时删除。
Stc不会更新/删除refs/stc/
之外的任何refs。
配置
Stc将一些设置放入$REPO/.git/config
-
日志.excludeDecoration=引用/stc/
用于在
git log
输出中隐藏跟踪refs。 -
传输.hideRefs=引用/stc/
可能过于谨慎。只是确保这些refs不会离开本地仓库。
-
stc.*
任何stc特定设置。
Stc只会修改仓库的配置。在--global
或--system
中设置这些设置是安全的。
Git命令
Stc主要使用两个命令来管理分支
-
gitrebase --committer-date-is-author-date --ontorefs/stc/base/<branch>refs/stc/start/<branch> <branch>
将分支rebase到其基分支,从start标记开始。如果有冲突,rebase将停止。解决冲突后,使用
--continue
或--abort
。在成功rebase后,start标记ref将被移动。 -
gitpush --set-upstream --force-with-lease=<branch>:<expected-commit> <远程> <branch>:<branch>
将分支推送到远程,可能会替换提交链,使远程分支看起来与本地分支完全一样。
<expected-commit>
是refs/stc/remote/<branch>
指向的。
此外,stc还使用一些其他命令来帮助跟踪事物,如for-each-ref
、update-ref
、symbolic-ref
、check-ref-format
。
依赖关系
~8MB
~136K SLoC