解决 Git 合并冲突

记录一次解决 Git 合并的经历。


2024.5.21

stable-diffusion-webui 项目中存在几个能够加速的 PR,但是这些 PR 并没有合并进这个项目中,于是打算自己合并这几个 PR。

能起到加速作用的 PR 有以下几个:

  1. [Performance 1/6] use_checkpoint = False #15803
  2. [Performance 2/6] Replace einops.rearrange with torch native ops #15804
  3. [Performance 4/6] Precompute is_sdxl_inpaint flag #15806
  4. [Performance 5/6] Prevent unnecessary extra networks bias backup #15816
  5. [Performance 6/6] Add –precision half option to avoid casting during inference #15820
  6. LDM optimization patches #15824

我将这几个 PR 合并进项目的 dev 分支,此时的 Commit 为 ddb28b33a3561a360b429c76f28f7ff1ffe282a0。尝试将上面的 PR 按顺序合并进 dev 分支中,前 5 个的合并很顺利,但是在合并第 6 个 PR 时出现了冲突,Github 提示我需要手动解决这个冲突。

  1. 将出现合并冲突的仓库克隆下来。

    1
    2
    3
    4
    5
    6
    7
    8
    $ git clone git@github.com:drhead/stable-diffusion-webui.git
    正克隆到 'stable-diffusion-webui'...
    remote: Enumerating objects: 32742, done.
    remote: Counting objects: 100% (36/36), done.
    remote: Compressing objects: 100% (21/21), done.
    remote: Total 32742 (delta 21), reused 26 (delta 15), pack-reused 32706
    接收对象中: 100% (32742/32742), 34.44 MiB | 4.33 MiB/s, 完成.
    处理 delta 中: 100% (22900/22900), 完成.
  2. 在仓库中把分支切换到要合并 PR 的那个 patch-4 分支。

    1
    2
    3
    4
    5
    $ git checkout patch-4
    分支 'patch-4' 设置为跟踪 'origin/patch-4'
    切换到一个新分支 'patch-4'
    $ git pull
    已经是最新的。
  3. 现在将分支切换到要合并到的 dev 分支中。

    1
    2
    3
    $ git checkout dev
    分支 'dev' 设置为跟踪 'origin/dev'
    切换到一个新分支 'dev'
  4. 将远程地址切换成自己已经合并前 5 个 PR 的项目地址上,并拉取更新。

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    $ git remote set-url origin git@github.com:licyk/stable-diffusion-webui.git
    $ git pull --rebase
    remote: Enumerating objects: 155, done.
    remote: Counting objects: 100% (141/141), done.
    remote: Compressing objects: 100% (57/57), done.
    remote: Total 155 (delta 98), reused 110 (delta 84), pack-reused 14
    接收对象中: 100% (155/155), 81.73 KiB | 186.00 KiB/s, 完成.
    处理 delta 中: 100% (100/100), 完成 13 个本地对象.
    来自 github.com:licyk/stable-diffusion-webui
    0a271938..530b2ec9 dev -> origin/dev
    * [新分支] dev-bak -> origin/dev-bak
    cf2772fa..b844cd8f master -> origin/master
    * [新分支] merge-all-perf -> origin/merge-all-perf
    * [新分支] perf -> origin/perf
    * [新分支] tmp -> origin/tmp
    * [新分支] tmp-1 -> origin/tmp-1
    * [新分支] tmp-2 -> origin/tmp-2
    * [新分支] tmp-3 -> origin/tmp-3
    更新 0a271938..530b2ec9
    Fast-forward
    .eslintrc.js | 2 +
    .github/workflows/on_pull_request.yaml | 10 +-
    .github/workflows/run_tests.yaml | 10 +-
    .gitignore | 1 +
    CHANGELOG.md | 301 +++++++++++++++++++++++++++++++++++-
    README.md | 1 +
    _typos.toml | 5 +
    configs/alt-diffusion-inference.yaml | 2 +-
    configs/alt-diffusion-m18-inference.yaml | 2 +-
    configs/instruct-pix2pix.yaml | 2 +-
    configs/sd_xl_inpaint.yaml | 2 +-
    configs/v1-inference.yaml | 2 +-
    configs/v1-inpainting-inference.yaml | 2 +-
    extensions-builtin/LDSR/sd_hijack_ddpm_v1.py | 8 +-
    extensions-builtin/Lora/lyco_helpers.py | 2 +-
    extensions-builtin/Lora/network.py | 34 +++-
    extensions-builtin/Lora/network_oft.py | 58 ++++---
    extensions-builtin/Lora/networks.py | 18 ++-
    extensions-builtin/Lora/ui_edit_user_metadata.py | 2 +
    extensions-builtin/Lora/ui_extra_networks_lora.py | 2 +-
    extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js | 53 +++++--
    extensions-builtin/canvas-zoom-and-pan/scripts/hotkey_config.py | 4 +-
    extensions-builtin/extra-options-section/scripts/extra_options_section.py | 8 +-
    .../postprocessing-for-training/scripts/postprocessing_autosized_crop.py | 0
    .../postprocessing-for-training/scripts}/postprocessing_caption.py | 0
    .../scripts}/postprocessing_create_flipped_copies.py | 0
    .../postprocessing-for-training/scripts}/postprocessing_focal_crop.py | 0
    .../postprocessing-for-training/scripts}/postprocessing_split_oversized.py | 2 +-
    extensions-builtin/soft-inpainting/scripts/soft_inpainting.py | 28 +++-
    html/extra-networks-copy-path-button.html | 2 +-
    html/extra-networks-edit-item-button.html | 2 +-
    html/extra-networks-metadata-button.html | 2 +-
    html/extra-networks-pane-dirs.html | 8 +
    html/extra-networks-pane-tree.html | 8 +
    html/extra-networks-pane.html | 64 +++++---
    javascript/aspectRatioOverlay.js | 12 +-
    javascript/dragdrop.js | 27 +++-
    javascript/edit-attention.js | 8 +
    javascript/extraNetworks.js | 177 ++++++++++++++-------
    javascript/imageviewer.js | 12 +-
    javascript/profilerVisualization.js | 207 ++++++++++++++-----------
    javascript/resizeHandle.js | 170 +++++++++++++-------
    javascript/settings.js | 4 +-
    javascript/ui.js | 7 +-
    modules/api/api.py | 26 +++-
    modules/api/models.py | 9 +-
    modules/cache.py | 92 +++++------
    modules/call_queue.py | 4 +-
    modules/cmd_args.py | 8 +-
    modules/codeformer_model.py | 2 +-
    modules/devices.py | 26 +++-
    modules/extensions.py | 63 +++++++-
    modules/extra_networks.py | 2 +-
    modules/hypernetworks/hypernetwork.py | 5 +-
    modules/images.py | 81 +++++++++-
    modules/img2img.py | 29 ++--
    modules/infotext_utils.py | 56 +++++--
    modules/infotext_versions.py | 4 +
    modules/initialize.py | 5 +-
    modules/initialize_util.py | 7 +
    modules/launch_utils.py | 2 +-
    modules/mac_specific.py | 2 +-
    modules/masking.py | 42 +++--
    modules/modelloader.py | 6 +-
    modules/models/diffusion/ddpm_edit.py | 8 +-
    modules/options.py | 3 +
    modules/paths_internal.py | 4 +-
    modules/postprocessing.py | 14 +-
    modules/processing.py | 182 ++++++++++++++--------
    modules/processing_scripts/comments.py | 7 +
    modules/processing_scripts/sampler.py | 45 ++++++
    modules/rng.py | 4 +-
    modules/script_callbacks.py | 248 ++++++++++++++++++++---------
    modules/script_loading.py | 4 +
    modules/scripts.py | 141 +++++++++++------
    modules/scripts_postprocessing.py | 6 +-
    modules/sd_emphasis.py | 4 +-
    modules/sd_hijack_checkpoint.py | 9 +-
    modules/sd_hijack_clip.py | 10 +-
    modules/sd_hijack_optimizations.py | 18 ++-
    modules/sd_hijack_unet.py | 29 +++-
    modules/sd_hijack_utils.py | 26 ++--
    modules/sd_models.py | 85 ++++++++--
    modules/sd_models_config.py | 2 +-
    modules/sd_models_xl.py | 13 +-
    modules/sd_samplers.py | 73 ++++++++-
    modules/sd_samplers_cfg_denoiser.py | 2 +-
    modules/sd_samplers_common.py | 15 +-
    modules/sd_samplers_kdiffusion.py | 88 +++++------
    modules/sd_schedulers.py | 43 ++++++
    modules/shared.py | 32 ++--
    modules/shared_init.py | 8 +
    modules/shared_items.py | 42 +++++
    modules/shared_options.py | 21 ++-
    modules/shared_state.py | 4 +-
    modules/styles.py | 3 +-
    modules/textual_inversion/autocrop.py | 4 +-
    modules/textual_inversion/dataset.py | 5 +-
    modules/textual_inversion/image_embedding.py | 14 +-
    modules/textual_inversion/{logging.py => saving_settings.py} | 0
    modules/textual_inversion/textual_inversion.py | 4 +-
    modules/txt2img.py | 5 +-
    modules/ui.py | 48 ++----
    modules/ui_common.py | 33 +---
    modules/ui_components.py | 2 +-
    modules/ui_extensions.py | 7 +-
    modules/ui_extra_networks.py | 163 ++++++++++++++-----
    modules/ui_extra_networks_user_metadata.py | 10 +-
    modules/ui_loadsave.py | 2 +
    modules/ui_postprocessing.py | 2 +-
    modules/ui_prompt_styles.py | 2 +-
    modules/ui_settings.py | 12 +-
    modules/ui_tempdir.py | 4 +-
    modules/upscaler.py | 7 +-
    modules/upscaler_utils.py | 4 +-
    modules/util.py | 75 +++++++++
    pyproject.toml | 6 +-
    requirements.txt | 2 +
    requirements_versions.txt | 2 +
    scripts/outpainting_mk_2.py | 2 +-
    scripts/postprocessing_codeformer.py | 2 +-
    scripts/postprocessing_gfpgan.py | 2 +-
    scripts/postprocessing_upscale.py | 74 +++++++--
    scripts/xyz_grid.py | 18 ++-
    style.css | 52 +++++--
    webui.sh | 33 ++--
    126 files changed, 2559 insertions(+), 972 deletions(-)
    create mode 100644 _typos.toml
    rename scripts/processing_autosized_crop.py => extensions-builtin/postprocessing-for-training/scripts/postprocessing_autosized_crop.py (100%)
    rename {scripts => extensions-builtin/postprocessing-for-training/scripts}/postprocessing_caption.py (100%)
    rename {scripts => extensions-builtin/postprocessing-for-training/scripts}/postprocessing_create_flipped_copies.py (100%)
    rename {scripts => extensions-builtin/postprocessing-for-training/scripts}/postprocessing_focal_crop.py (100%)
    rename {scripts => extensions-builtin/postprocessing-for-training/scripts}/postprocessing_split_oversized.py (95%)
    create mode 100644 html/extra-networks-pane-dirs.html
    create mode 100644 html/extra-networks-pane-tree.html
    create mode 100644 modules/processing_scripts/sampler.py
    create mode 100644 modules/sd_schedulers.py
    rename modules/textual_inversion/{logging.py => saving_settings.py} (100%)
  5. 尝试将出现冲突的 patch-4 分支合并到 dev 分支中。

    1
    2
    3
    4
    $ git merge --no-ff patch-4
    自动合并 modules/sd_hijack_unet.py
    冲突(内容):合并冲突于 modules/sd_hijack_unet.py
    自动合并失败,修正冲突然后提交修正的结果。
  6. 此时这里提示合并冲突,需要修改冲突的部分。

    1
    $ lvim modules/sd_hijack_unet.py

这是冲突的代码部分。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
ddpm_edit_hijack = None
def hijack_ddpm_edit():
global ddpm_edit_hijack
if not ddpm_edit_hijack:
CondFunc('modules.models.diffusion.ddpm_edit.LatentDiffusion.decode_first_stage', first_stage_sub, first_stage_cond)
CondFunc('modules.models.diffusion.ddpm_edit.LatentDiffusion.encode_first_stage', first_stage_sub, first_stage_cond)
ddpm_edit_hijack = CondFunc('modules.models.diffusion.ddpm_edit.LatentDiffusion.apply_model', apply_model)


unet_needs_upcast = lambda *args, **kwargs: devices.unet_needs_upcast
<<<<<<< HEAD

=======
CondFunc('ldm.models.diffusion.ddpm.LatentDiffusion.apply_model', apply_model, unet_needs_upcast)
CondFunc('ldm.modules.diffusionmodules.openaimodel.timestep_embedding', timestep_embedding, lambda *args, **kwargs: True)
CondFunc('ldm.modules.attention.SpatialTransformer.forward', spatial_transformer_forward, lambda *args, **kwargs: True)
CondFunc('ldm.modules.diffusionmodules.openaimodel.timestep_embedding', lambda orig_func, timesteps, *args, **kwargs: orig_func(timesteps, *args, **kwargs).to(torch.float32 if timesteps.dtype == torch.int64 else devices.dtype_unet), unet_needs_upcast)
>>>>>>> patch-4
if version.parse(torch.__version__) <= version.parse("1.13.2") or torch.cuda.is_available():
CondFunc('ldm.modules.diffusionmodules.util.GroupNorm32.forward', lambda orig_func, self, *args, **kwargs: orig_func(self.float(), *args, **kwargs), unet_needs_upcast)
CondFunc('ldm.modules.attention.GEGLU.forward', lambda orig_func, self, x: orig_func(self.float(), x.float()).to(devices.dtype_unet), unet_needs_upcast)
CondFunc('open_clip.transformer.ResidualAttentionBlock.__init__', lambda orig_func, *args, **kwargs: kwargs.update({'act_layer': GELUHijack}) and False or orig_func(*args, **kwargs), lambda _, *args, **kwargs: kwargs.get('act_layer') is None or kwargs['act_layer'] == torch.nn.GELU)

first_stage_cond = lambda _, self, *args, **kwargs: devices.unet_needs_upcast and self.model.diffusion_model.dtype == torch.float16
first_stage_sub = lambda orig_func, self, x, **kwargs: orig_func(self, x.to(devices.dtype_vae), **kwargs)
CondFunc('ldm.models.diffusion.ddpm.LatentDiffusion.decode_first_stage', first_stage_sub, first_stage_cond)
CondFunc('ldm.models.diffusion.ddpm.LatentDiffusion.encode_first_stage', first_stage_sub, first_stage_cond)
CondFunc('ldm.models.diffusion.ddpm.LatentDiffusion.get_first_stage_encoding', lambda orig_func, *args, **kwargs: orig_func(*args, **kwargs).float(), first_stage_cond)

CondFunc('ldm.models.diffusion.ddpm.LatentDiffusion.apply_model', apply_model)
CondFunc('sgm.modules.diffusionmodules.wrappers.OpenAIWrapper.forward', apply_model)

在起冲突的地方,Git 使用一些标识将两个冲突的部分划分了出来。

1
2
3
4
5
6
7
8
<<<<<<< HEAD        # 这是原有 dev 分支的部分

======= # 这是两个不同代码部分的分隔标记
CondFunc('ldm.models.diffusion.ddpm.LatentDiffusion.apply_model', apply_model, unet_needs_upcast)
CondFunc('ldm.modules.diffusionmodules.openaimodel.timestep_embedding', timestep_embedding, lambda *args, **kwargs: True)
CondFunc('ldm.modules.attention.SpatialTransformer.forward', spatial_transformer_forward, lambda *args, **kwargs: True)
CondFunc('ldm.modules.diffusionmodules.openaimodel.timestep_embedding', lambda orig_func, timesteps, *args, **kwargs: orig_func(timesteps, *args, **kwargs).to(torch.float32 if timesteps.dtype == torch.int64 else devices.dtype_unet), unet_needs_upcast)
>>>>>>> patch-4 # 这是合并进来的 patch-4 分支的部分

解决冲突的时需要将上面注释的部分删除,修改后的结果如下。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
ddpm_edit_hijack = None
def hijack_ddpm_edit():
global ddpm_edit_hijack
if not ddpm_edit_hijack:
CondFunc('modules.models.diffusion.ddpm_edit.LatentDiffusion.decode_first_stage', first_stage_sub, first_stage_cond)
CondFunc('modules.models.diffusion.ddpm_edit.LatentDiffusion.encode_first_stage', first_stage_sub, first_stage_cond)
ddpm_edit_hijack = CondFunc('modules.models.diffusion.ddpm_edit.LatentDiffusion.apply_model', apply_model)


unet_needs_upcast = lambda *args, **kwargs: devices.unet_needs_upcast

CondFunc('ldm.models.diffusion.ddpm.LatentDiffusion.apply_model', apply_model, unet_needs_upcast)
CondFunc('ldm.modules.diffusionmodules.openaimodel.timestep_embedding', timestep_embedding, lambda *args, **kwargs: True)
CondFunc('ldm.modules.attention.SpatialTransformer.forward', spatial_transformer_forward, lambda *args, **kwargs: True)
CondFunc('ldm.modules.diffusionmodules.openaimodel.timestep_embedding', lambda orig_func, timesteps, *args, **kwargs: orig_func(timesteps, *args, **kwargs).to(torch.float32 if timesteps.dtype == torch.int64 else devices.dtype_unet), unet_needs_upcast)

if version.parse(torch.__version__) <= version.parse("1.13.2") or torch.cuda.is_available():
CondFunc('ldm.modules.diffusionmodules.util.GroupNorm32.forward', lambda orig_func, self, *args, **kwargs: orig_func(self.float(), *args, **kwargs), unet_needs_upcast)
CondFunc('ldm.modules.attention.GEGLU.forward', lambda orig_func, self, x: orig_func(self.float(), x.float()).to(devices.dtype_unet), unet_needs_upcast)
CondFunc('open_clip.transformer.ResidualAttentionBlock.__init__', lambda orig_func, *args, **kwargs: kwargs.update({'act_layer': GELUHijack}) and False or orig_func(*args, **kwargs), lambda _, *args, **kwargs: kwargs.get('act_layer') is None or kwargs['act_layer'] == torch.nn.GELU)

first_stage_cond = lambda _, self, *args, **kwargs: devices.unet_needs_upcast and self.model.diffusion_model.dtype == torch.float16
first_stage_sub = lambda orig_func, self, x, **kwargs: orig_func(self, x.to(devices.dtype_vae), **kwargs)
CondFunc('ldm.models.diffusion.ddpm.LatentDiffusion.decode_first_stage', first_stage_sub, first_stage_cond)
CondFunc('ldm.models.diffusion.ddpm.LatentDiffusion.encode_first_stage', first_stage_sub, first_stage_cond)
CondFunc('ldm.models.diffusion.ddpm.LatentDiffusion.get_first_stage_encoding', lambda orig_func, *args, **kwargs: orig_func(*args, **kwargs).float(), first_stage_cond)

CondFunc('ldm.models.diffusion.ddpm.LatentDiffusion.apply_model', apply_model)
CondFunc('sgm.modules.diffusionmodules.wrappers.OpenAIWrapper.forward', apply_model)
  1. 保存这个文件后,将这个文件添加到 Git 的暂存区,并提交更改。
    1
    2
    $ git add modules/sd_hijack_unet.py
    $ git commit

这里打开了提交信息编辑器,让我编辑提交信息。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Merge branch 'patch-4' into dev

# Conflicts:
# modules/sd_hijack_unet.py
#
# 似乎您正在做一个合并提交。如果不对,请运行
# git update-ref -d MERGE_HEAD
# 然后重试。


# 请为您的变更输入提交说明。以 '#' 开始的行将被忽略,而一个空的提交
# 说明将会终止提交。
#
# 位于分支 dev
# 您的分支与上游分支 'origin/dev' 一致。
#
# 所有冲突已解决但您仍处于合并中。
#
# 要提交的变更:
# 修改: modules/sd_hijack_unet.py
#

这个提交信息不需要修改,直接保存,保存后会显示最终的提交信息。

1
[dev 73d652d0] Merge branch 'patch-4' into dev
  1. 这时冲突已经完全解决,将这个分支提交到远程仓库中。
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    $ git push origin dev
    枚举对象中: 10, 完成.
    对象计数中: 100% (10/10), 完成.
    使用 16 个线程进行压缩
    压缩对象中: 100% (4/4), 完成.
    写入对象中: 100% (4/4), 663 字节 | 331.00 KiB/s, 完成.
    总共 4(差异 3),复用 0(差异 0),包复用 0(来自 0 个包)
    remote: Resolving deltas: 100% (3/3), completed with 3 local objects.
    To github.com:licyk/stable-diffusion-webui.git
    530b2ec9..73d652d0 dev -> dev

2024.5.29

原项目更新后,我需要将这些更新同步到自己的分支上,所以我需要将原项目的分支添加到自己的仓库上

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
$ git remote add a1111 https://github.com/AUTOMATIC1111/stable-diffusion-webui  # 添加原项目的仓库地址
$ git branch a1111-master # 新建一个分支用于连接原项目的仓库
$ git checkout a1111-master # 切换到这个新分支
$ git fetch a1111 # 从原项目的远程仓库中拉取更新到这个仓库
remote: Enumerating objects: 20, done.
remote: Counting objects: 100% (20/20), done.
remote: Compressing objects: 100% (18/18), done.
remote: Total 20 (delta 8), reused 10 (delta 2), pack-reused 0
展开对象中: 100% (20/20), 38.86 KiB | 1020.00 KiB/s, 完成.
来自 https://github.com/AUTOMATIC1111/stable-diffusion-webui
* [新分支] Inpaint-Only-masked-blank-mask -> a1111/Inpaint-Only-masked-blank-mask
* [新分支] ReloadUI-backgroundColor---background-fill-primary -> a1111/ReloadUI-backgroundColor---background-fill-primary
* [新分支] api-old-sampler-names -> a1111/api-old-sampler-names
* [新分支] bump-Pillow-blendmodes-dependency -> a1111/bump-Pillow-blendmodes-dependency
* [新分支] compact-Soft-Inpainting-infotext -> a1111/compact-Soft-Inpainting-infotext
* [新分支] consistency-dec -> a1111/consistency-dec
* [新分支] create_infotext-index-and-callable -> a1111/create_infotext-index-and-callable
* [新分支] dev -> a1111/dev
* [新分支] drag-text-fix -> a1111/drag-text-fix
* [新分支] fix-Hypertile-xyz -> a1111/fix-Hypertile-xyz
* [新分支] fix-change-log -> a1111/fix-change-log
* [新分支] fix-corrupt-model-loop -> a1111/fix-corrupt-model-loop
* [新分支] fix-default-in-get_learned_conditioning -> a1111/fix-default-in-get_learned_conditioning
* [新分支] fix-extention-update-when-not-on-main-branch -> a1111/fix-extention-update-when-not-on-main-branch
* [新分支] fix-extra-batch-mode-P-Transparency -> a1111/fix-extra-batch-mode-P-Transparency
* [新分支] fix-fonts-with-subpath- -> a1111/fix-fonts-with-subpath-
* [新分支] fix_p_invalid_sampler_and_scheduler -> a1111/fix_p_invalid_sampler_and_scheduler
* [新分支] gradio-4.x-test -> a1111/gradio-4.x-test
* [新分支] gradio4 -> a1111/gradio4
* [新分支] initial-model-download-integrity -> a1111/initial-model-download-integrity
* [新分支] lora-bundled-TI-infotext -> a1111/lora-bundled-TI-infotext
* [新分支] lora_emb_bundle -> a1111/lora_emb_bundle
* [新分支] master -> a1111/master
* [新分支] more-extra-transparency-fix-again -> a1111/more-extra-transparency-fix-again
* [新分支] no-referrer -> a1111/no-referrer
* [新分支] patch__pkg_resources__packaging -> a1111/patch__pkg_resources__packaging
* [新分支] refiner_alt -> a1111/refiner_alt
* [新分支] release_candidate -> a1111/release_candidate
* [新分支] revert-use-of-gitpython-hijack -> a1111/revert-use-of-gitpython-hijack
* [新分支] sqlite-cache -> a1111/sqlite-cache
* [新分支] torch-float64-or-float32 -> a1111/torch-float64-or-float32
* [新分支] use-script_path-for-webui-root-in-launch_utils -> a1111/use-script_path-for-webui-root-in-launch_utils
* [新分支] xyz-csv-skipinitialspace -> a1111/xyz-csv-skipinitialspace
* [新分支] xyz-override-rework -> a1111/xyz-override-rework
* [新标签] v1.9.4 -> v1.9.4
$ git branch -u a1111/master # 将这个分支本地分支和原项目仓库的 master 分支连接上
分支 'a1111-master' 设置为跟踪 'a1111/master'

这样就在本地的仓库中添加了原项目的地址,并创建了一个新分支来连接这个地址。

现在回到自己的的分支上并合并原仓库的更新。

1
2
3
4
5
6
7
8
9
$ git checkout master       # 切换分支
切换到分支 'master'
您的分支与上游分支 'origin/master' 一致。
$ git merge a1111/master # 从原项目的 master 分支合并更新
Merge made by the 'ort' strategy.
CHANGELOG.md | 5 +++++
requirements_versions.txt | 1 +
2 files changed, 6 insertions(+)
$ git push # 将合并厚的结果推送到自己的远程仓库

另外发现一个更加合适的合并分支的方式,这里先把自己的仓库的提交信息回退到之前要解决冲突的提交信息上,用作演示。

1
2
$ git reset --hard 530b2ec9435806bf34ed462a003d611b9d32c38b
HEAD 现在位于 530b2ec9 Merge pull request #5 from huchenlei/force_half

将那个要合并那个加速补丁的仓库的地址添加到本地仓库,并拉取内容到本地仓库中。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
$ git remote add drhead https://github.com/drhead/stable-diffusion-webui
$ git pull drhead
来自 https://github.com/drhead/stable-diffusion-webui
* [新分支] add-Block-component-creation-callback -> drhead/add-Block-component-creation-callback
* [新分支] bump-Pillow-blendmodes-dependency -> drhead/bump-Pillow-blendmodes-dependency
* [新分支] consistency-dec -> drhead/consistency-dec
* [新分支] dev -> drhead/dev
* [新分支] fix-Auto-focal-point-crop-for-opencv-4.8.x -> drhead/fix-Auto-focal-point-crop-for-opencv-4.8.x
* [新分支] lora_emb_bundle -> drhead/lora_emb_bundle
* [新分支] master -> drhead/master
* [新分支] patch-1 -> drhead/patch-1
* [新分支] patch-2 -> drhead/patch-2
* [新分支] patch-3 -> drhead/patch-3
* [新分支] patch-4 -> drhead/patch-4
* [新分支] patch-5 -> drhead/patch-5
* [新分支] protect-against-bad-ui-creation-scripts -> drhead/protect-against-bad-ui-creation-scripts
* [新分支] refiner_alt -> drhead/refiner_alt
* [新分支] refiner_cumprod_fix -> drhead/refiner_cumprod_fix
* [新分支] refiner_fix -> drhead/refiner_fix
* [新分支] release_candidate -> drhead/release_candidate
* [新分支] revert-use-of-gitpython-hijack -> drhead/revert-use-of-gitpython-hijack
* [新分支] sqlite-cache -> drhead/sqlite-cache
* [新分支] test-fp8 -> drhead/test-fp8
* [新分支] torch210 -> drhead/torch210
* [新分支] zero-terminal-snr -> drhead/zero-terminal-snr
您要求从远程 'drhead' 拉取,但是未指定一个分支。因为这不是当前
分支默认的远程仓库,您必须在命令行中指定一个分支名。

虽然 Git 提示未指定一个分支,但是那个仓库的内容已经拉取下来了,这时候可以合并那个仓库中的加速补丁的分支。

1
2
3
4
$ git merge drhead/patch-4
自动合并 modules/sd_hijack_unet.py
冲突(内容):合并冲突于 modules/sd_hijack_unet.py
自动合并失败,修正冲突然后提交修正的结果。

和之前的解决冲突时的提示一样,按照之前的方法解决冲突就行。相比之前去解决冲突的方法,这个方法更加便捷,可以省去一些步骤。


2024.6.23

这次试着把 [WIP] Asynchronous model mover for lowvram by wfjsw · Pull Request #14855 · AUTOMATIC1111/stable-diffusion-webui 这个 PR 合并。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
$ git remote add wfjsw https://github.com/wfjsw/stable-diffusion-webui # 添加要合并分支的远程源
$ git fetch wfjsw # 拉取这个远程源的内容
remote: Enumerating objects: 115, done.
remote: Counting objects: 100% (66/66), done.
remote: Total 115 (delta 66), reused 66 (delta 66), pack-reused 49
接收对象中: 100% (115/115), 64.49 KiB | 217.00 KiB/s, 完成.
处理 delta 中: 100% (83/83), 完成 34 个本地对象.
来自 https://github.com/wfjsw/stable-diffusion-webui
* [新分支] Zoom-Alt-instead-of-Shift -> wfjsw/Zoom-Alt-instead-of-Shift
* [新分支] api-quit-restart -> wfjsw/api-quit-restart
* [新分支] cfg-rescale -> wfjsw/cfg-rescale
* [新分支] context-menus-dynamic -> wfjsw/context-menus-dynamic
* [新分支] dag -> wfjsw/dag
* [新分支] dev -> wfjsw/dev
* [新分支] ext-index-env -> wfjsw/ext-index-env
* [新分支] ext-inst-pbar -> wfjsw/ext-inst-pbar
* [新分支] extension-index-exception -> wfjsw/extension-index-exception
* [新分支] fix-calc_resolution_hires -> wfjsw/fix-calc_resolution_hires
* [新分支] fix-env-get -> wfjsw/fix-env-get
* [新分支] fix-env-get-1 -> wfjsw/fix-env-get-1
* [新分支] git-clone-autofix -> wfjsw/git-clone-autofix
* [新分支] git-clone-progress -> wfjsw/git-clone-progress
* [新分支] master -> wfjsw/master
* [新分支] model-mover -> wfjsw/model-mover
* [新分支] move-from-sysinfo-to-errors -> wfjsw/move-from-sysinfo-to-errors
* [新分支] move-start-timer -> wfjsw/move-start-timer
* [新分支] patch-1 -> wfjsw/patch-1
* [新分支] prepend-pythonpath -> wfjsw/prepend-pythonpath
* [新分支] release_candidate -> wfjsw/release_candidate
* [新分支] revert-11244 -> wfjsw/revert-11244
* [新分支] revert-use-of-gitpython-hijack -> wfjsw/revert-use-of-gitpython-hijack
* [新分支] running-without-autocast -> wfjsw/running-without-autocast
* [新分支] state-dict-ref-comparison -> wfjsw/state-dict-ref-comparison
* [新分支] typo-fix-1 -> wfjsw/typo-fix-1
* [新分支] use-ext-name-for-installed -> wfjsw/use-ext-name-for-installed
* [新分支] v1.2.0-hotfix -> wfjsw/v1.2.0-hotfix
$ git fetch a1111 # 拉取官方的更新内容
remote: Enumerating objects: 215, done.
remote: Counting objects: 100% (206/206), done.
remote: Compressing objects: 100% (112/112), done.
remote: Total 215 (delta 123), reused 161 (delta 94), pack-reused 9
接收对象中: 100% (215/215), 171.97 KiB | 1.05 MiB/s, 完成.
处理 delta 中: 100% (123/123), 完成 11 个本地对象.
来自 https://github.com/AUTOMATIC1111/stable-diffusion-webui
* [新分支] ToggleLivePriview-in-image-viewer -> a1111/ToggleLivePriview-in-image-viewer
547778b1..a30b19dd dev -> a1111/dev
* [新分支] fix-Sampler-Scheduler-autocorrection-warning -> a1111/fix-Sampler-Scheduler-autocorrection-warning
* [新分支] fix-infotext-Lora-hashes-fro-hires-fix-different-lora -> a1111/fix-infotext-Lora-hashes-fro-hires-fix-different-lora
* [新分支] remove-dont_fix_second_order_samplers_schedule -> a1111/remove-dont_fix_second_order_samplers_schedule
* [新分支] sd3 -> a1111/sd3
$ git merge a1111/dev # 合并一下更新
更新 547778b1..a30b19dd
Fast-forward
.gitignore | 1 +
javascript/progressbar.js | 22 ++++++++++++++++++++++
javascript/ui.js | 1 +
modules/call_queue.py | 10 ++++++++--
modules/images.py | 15 ++++++++++-----
modules/processing.py | 38 ++++++++++++++++++++++++++++++++++----
modules/profiling.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++
modules/scripts.py | 15 +++++++++++++++
modules/sd_hijack_clip.py | 4 +++-
modules/sd_models.py | 20 +++++++++++++-------
modules/sd_samplers_cfg_denoiser.py | 4 +---
modules/sd_samplers_kdiffusion.py | 4 ++--
modules/sd_schedulers.py | 18 +++++++++++++-----
modules/shared_options.py | 18 ++++++++++++++++++
script.js | 15 +++++++++++++++
scripts/xyz_grid.py | 8 +++++---
style.css | 6 +++++-
17 files changed, 212 insertions(+), 33 deletions(-)
create mode 100644 modules/profiling.py
$ git branch lowvram # 建一个新分支来合并新的内容
$ git checkout lowvram
切换到分支 'lowvram'
$ git merge wfjsw/model-mover
自动合并 modules/devices.py
冲突(内容):合并冲突于 modules/devices.py
自动合并 modules/processing.py
冲突(内容):合并冲突于 modules/processing.py
自动合并 modules/sd_models.py
自动合并 modules/shared_options.py
自动合并失败,修正冲突然后提交修正的结果。
$ lvim modules/devices.py # 和以前的方法一样解决冲突
$ lvim modules/processing.py
$ git add . # 再把解决冲突后的内容添加进去
$ git commit
[lowvram 202f6d3a] Merge remote-tracking branch 'wfjsw/model-mover' into lowvram
$ git push --set-upstream origin lowvram

解决 Git 合并冲突
http://licyk.github.io/2024/05/21/resolve-git-conflict/
作者
licyk
发布于
2024年5月21日
许可协议