git存储库中是否有任何分支的线性提交历史记录?如何将其指定为git格式的补丁


  1. git存储库中的任何分支头是否存在线性提交历史记录,一直到空的git repo?本质上是其历史中的一个提交列表,当按顺序应用时,谁的diff可以将空的repo恢复到分支的当前状态
  2. 是否存在";git格式补丁";可以提取线性提交历史记录的命令
  3. 具体地说,所提取的一系列补丁应该可以与"补丁"一起使用;gitinit;git-am-patches.txt";重建最新的分支头状态,而不会遇到补丁冲突

即使这意味着需要一些脚本来实现我上面想要的。

-----最初提出的问题--------

我有一个数字报告,说分支机构X

我想生成一个补丁序列;git格式补丁";我可以用它来重建一个全新的git repo;git-am/apply";从零开始(gitinit(,只有一个branchX及其完整历史记录返回到提交零。

目前,我尝试从repoA 获得如下补丁

git --no-pager format-patch --binary --stdout --root branchX > patch.list
OR
# f7ef86f26066fb428305f3809309ba33d70a9feb is considered the zero/empty state/commit of any git repo
git --no-pager format-patch --binary --stdout --root f7ef86f26066fb428305f3809309ba33d70a9feb branchX > patch.list
cd /path/to/repoNew
git init
git am --3way patch.list
OR
git am patch.list

但是有些补丁列表是如何通过上面的格式生成的补丁命令

bash-4.2$ git am --3way /witspace/sarvi/space_sarvi_mynxos/kwaiclean/boot/t
Applying: Initial branch reference point created
applying to an empty history
Applying: Admin created refpoint (likely to handle manual repository mucking)
Applying: new-module-makes
Applying: new-module-makes
Applying: new file for sienna target
Applying: change the rule for specifying EXTRA_*
Applying: Removing Makefile.am files and modifying copyright entry
Applying: changes for bringing up isan-image on maui
Applying: Adding group 'routing-sw' to /etc/group. The routing-sw components will be             
started by sysmgr in process group 'routing-sw'. This will allow us to kill/ restart 
all routing-sw components without rebooting Linux/SANOS.
Applying: added a new dhcpd.conf file that is specific to 13-slot
Applying: modify the /etc/dhcpd.conf in each lc-line entry to specifiy the slot 
number as     part of creating DHCP links to correct LCImage
Applying: Update build infrastructure for DC3 builds
Applying: Use our own passwd/group files instead of using the one in basefs
Using index info to reconstruct a base tree...
M       aci/bootglobalpkg/group
.git/rebase-apply/patch:34: new blank line at EOF.
+
warning: 1 line adds whitespace errors.
Falling back to patching base and 3-way merge...
Auto-merging aci/bootglobalpkg/group
Applying: Changes for preparation of new restructure of workspace
Applying: DC-OS Codebase Restructure: Stage1 + Stage2 for branch sf
Using index info to reconstruct a base tree...
M       aci/bootbios_program/module.mk
Falling back to patching base and 3-way merge...
Auto-merging aci/bootbios_program/module.mk
CONFLICT (content): Merge conflict in aci/bootbios_program/module.mk
error: Failed to merge in the changes.
Patch failed at 0015 DC-OS Codebase Restructure: Stage1 + Stage2 for branch sf
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
bash-4.2$ 

我没有得到的是如果";git格式补丁";上面的命令以正确的顺序从源/原始git repo的初始化中获取/生成所有提交/补丁,以及";git am";命令只按相同的顺序应用它们,为什么会出现冲突?

如何做到这一点?

为什么不可能从一个分支头开始,线性地走到第一个提交,然后按顺序获得补丁序列,并将其应用于分支新的git repo中,以通过补丁再现线性历史。

git push path/to/new/repo branchX

如果你有一个从旧的repo到新repo的路径,就会这样做,或者如果路径托管在某个可以访问的地方,就会在url中进行sub。否则

git bundle create my.bundle branchX
# get my.bundle to the destination system somehow, then in your new repo
git fetch my.bundle branchX

我想生成一个补丁序列;git格式补丁";我可以用它来重建一个全新的git repo;git-am/apply";从零开始(gitinit(,只有一个branchX及其完整历史记录返回到提交零。

这是不适合这份工作的工具。正如@torek所指出的,格式化补丁是为补丁系列工作构建的,用于交流线性历史。

最新更新