gpt4 book ai didi

github - 可以在 GitHub 中自动同​​步 fork 吗?

转载 作者:行者123 更新时间:2023-12-03 09:09:11 30 4
gpt4 key购买 nike

如果选中,Stash 将启用自动 fork 同步:
https://confluence.atlassian.com/display/STASH/Keeping+forks+synchronized
它将更新您尚未修改的 fork 中的任何分支。
我一直无法在 GitHub 中找到类似的自动功能;所有的谷歌搜索都在寻找通过本地缓存同步 fork 的手动方式。

最佳答案

作为记录,最近我遇到了同样的问题,并通过 Github Actions 解决了这个问题。解决方案相当简单:计划的操作获取上游存储库并将其合并到我的存储库中。

# .github/workflows/example.yml

name: Merge upstream branches
on:
schedule:
# actually, ~5 minutes is the highest
# effective frequency you will get
- cron: '* * * * *'
jobs:
merge:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Merge upstream
run: |
git config --global user.name 'your-name'
git config --global user.email 'your-username@users.noreply.github.com'

# "git checkout master" is unnecessary, already here by default
git pull --unshallow # this option is very important, you would get
# complains about unrelated histories without it.
# (but actions/checkout@v2 can also be instructed
# to fetch all git depth right from the start)

git remote add upstream https://github.com/example/test.git
git fetch upstream

# Neither forget the -b opt,
# the feature/x ref is ambiguous at this stage
git checkout -b feature/x origin/feature/x
git merge --no-edit upstream/feature/x
git push origin feature/x

git checkout master
git merge --no-edit upstream/master
git push origin master

# etc


我每周日运行它,这对我来说绰绰有余。只需将其安排到适合您的任何地方。

此外,同步不同作业中的每个分支可能更明智,因为它们将并行运行,并且在发生冲突时可以独立成功或失败。

如果需要合并任意数量的分支,可以引用 How to fetch all Git branches 之类的问题找到外壳技巧来做到这一点。

我注意到存在一个公共(public)行动来通过重新定位来解决这个问题。它看起来很有希望,但它没有记录,所以这里是我的片段。希望能帮助到你!

关于github - 可以在 GitHub 中自动同​​步 fork 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23793062/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com