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

2022-02-26 11:50:57 +08:00
 MiketsuSmasher

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

1433 次点击
所在节点    问与答
8 条回复
zacharyjia
2022-02-26 12:01:59 +08:00
做两个分支,然后在不同平台上设置不同的默认分支?
foam
2022-02-26 12:27:00 +08:00
readme 不要放本地 git 就行了。在远程仓库管理
foam
2022-02-26 12:40:04 +08:00
sorry ,忽略了 git pull 会有问题。那方案就复杂点了:
1 ,弄个不在 git 管理的目录,放多个 readme
2 ,分支: master ,分支 g ,分支 n
3 ,推送时,分支 g n rebase master 分支,并分别 cp 对应的 readme ,push 到对应的远程即可

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

P.S. 为啥要区分 readme ?
MiketsuSmasher
2022-02-26 12:52:40 +08:00
@foam 详细的使用说明和许可证等信息不在 README.md 里面,在同一仓库的其他文件里,所以要根据托管平台修改对应文件的链接
0o0O0o0O0o
2022-02-26 12:58:39 +08:00
如果主要使用 Github ,那 git hooks 里对别的平台 sed + commit + force push + reset 不知道行不行
wzzzx
2022-02-26 13:15:27 +08:00
1 楼的方法应该是正解,只能维护俩分支了
windyskr
2022-02-26 16:05:28 +08:00
用相对路径试试?

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
2022-02-26 16:10:42 +08:00
ls 方案+1.

又是个 XY Problem

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/836549

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX