mok*_*tor 38 git atlassian-sourcetree
我目前正在开发一个SVN用作存储库的项目.在本地,我用代码进行了几次"实验",我不想承诺回购.因此,我在SVN工作目录的顶部本地使用git,并使用多个分支进行不同的"实验".所以它看起来像这样.
C0 ---- C7 (master)
\
\---- C1 ---- C2 ---- C4 (exp1)
\ \ \
\ \ \---- C3 (exp2)
\ \
\ \---- C5 (exp3)
\
\---- C6 (exp4)
Run Code Online (Sandbox Code Playgroud)
在分支上master我想要有无污染的SVN回购,即C0是SVN Repo Revision x,C7是SVN Repo Revision x + n.
以某种方式很容易地将所有exp分支重新固定到C7上,使树看起来像下图?
C0 ---- C7 (master)
\
\---- C1' ---- C2' ---- C4' (exp1)
\ \ \
\ \ \---- C3' (exp2)
\ \
\ \---- C5' (exp3)
\
\---- C6' (exp4)
Run Code Online (Sandbox Code Playgroud)
我想使用rebase,因为我不想修改本地SVN Checkout的状态,并希望我的更改建立在SVN修订版之上.
我也对在SourceTree中工作的解决方案感兴趣,而不必使用shell.
GoZ*_*ner 22
你无法一步到位.最好你逐一移动每个分支; 这将是序列:
git rebase --onto master exp1
git rebase --onto c2' c2 exp2
git rebase --onto c1' c1 exp3
git rebase --onto master exp4
Run Code Online (Sandbox Code Playgroud)
关键是从旧树中的每个分支点(例如上面的c2)到新树(例如上面的c2').
您可以使用一个小技巧来重新设置多个分支/树。
--no-ff合并) - 更新来自@kdb,@franckspike 的评论--preserve-merges为变基命令添加选项git reset --hard [Commit-hash of C4' (exp1)]小智 5
我只想提到GoZoner的序列在第一行(也是最后一行)中有一个错误。exp1不是上游,而是您要重新设置基准的分支。
为了启动顺序,你需要有主人的上游,即git rebase --onto master master exp1或短,没有--onto这将是git rebase master exp1。该问题示例的总正确顺序为:
git rebase master exp1
git rebase --onto c2' c2 exp2
git rebase --onto c1' c1 exp3
git rebase master exp4
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7136 次 |
| 最近记录: |