MiketsuSmasher
V2EX  ›  问与答

Git 如何根据不同远程仓库推送不同内容的 README

  •  
  •   MiketsuSmasher · Feb 26, 2022 via Android · 2330 views
    This topic created in 1712 days ago, the information mentioned may be changed or developed.

    我有个仓库,需要推送到 Github 和 Notabug 上。现在想要根据不同托管平台上的远程仓库,推送不同内容(主要是各种超链接不同)的 README ,有什么方法可以做到吗?

    8 replies  •  2022-02-26 16:10:42 +08:00
    unifier
    unifier
    Feb 26, 2022
    1
    做两个分支,然后在不同平台上设置不同的默认分支?
    foam
    foam
    Feb 26, 2022 via Android
    2
    readme 不要放本地 git 就行了。在远程仓库管理
    foam
    foam
    Feb 26, 2022 via Android
    3
    sorry ,忽略了 git pull 会有问题。那方案就复杂点了:
    1 ,弄个不在 git 管理的目录,放多个 readme
    2 ,分支: master ,分支 g ,分支 n
    3 ,推送时,分支 g n rebase master 分支,并分别 cp 对应的 readme ,push 到对应的远程即可

    以上这些命令自动化就行,弄个别名,简单方便。

    P.S. 为啥要区分 readme ?
    MiketsuSmasher
    MiketsuSmasher
    OP
    Feb 26, 2022
    4
    @foam 详细的使用说明和许可证等信息不在 README.md 里面,在同一仓库的其他文件里,所以要根据托管平台修改对应文件的链接
    0o0O0o0O0o
    0o0O0o0O0o
    Feb 26, 2022
    5
    如果主要使用 Github ,那 git hooks 里对别的平台 sed + commit + force push + reset 不知道行不行
    J55s5
    J55s5
    Feb 26, 2022
    6
    1 楼的方法应该是正解,只能维护俩分支了
    windyskr
    windyskr
    Feb 26, 2022 via iPhone❤️2
    7
    用相对路径试试?

    A relative link is a link that is relative to the current file. For example, if you have a README file in root of your repository, and you have another file in docs/CONTRIBUTING.md, the relative link to CONTRIBUTING.md in your README might look like this:

    [Contribution guidelines for this project](docs/CONTRIBUTING.md)

    GitHub will automatically transform your relative link or image path based on whatever branch you're currently on, so that the link or path always works. You can use all relative link operands, such as ./ and ../.

    https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-readmes
    Senorsen
    Senorsen
    Feb 26, 2022
    8
    ls 方案+1.

    又是个 XY Problem
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1291 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 22:21 · PVG 06:21 · LAX 14:21 · JFK 17:21
    ♥ Do have faith in what you're doing.