跳转到主内容

贡献者 Git 命令指南

非官方测试版翻译

本页面由 PageTurner AI 翻译(测试版)。未经项目官方认可。 发现错误? 报告问题 →

虽然我们都熟悉源代码管理,但使用 fork 仓库并确保顺畅合并会带来额外挑战。本文旨在帮助你处理那些可能需要操作但可能不太熟悉的场景。

放轻松,准备好你的毛巾(别慌)。

如果你不习惯使用命令行操作 Git,我们推荐 GitKraken。这是最好的跨平台 Git 工具,我们在下方也添加了相关使用说明。

未遵守常规提交规范

Open your oh-my-posh repo inside GitKraken and right click the commit you want to reword in the graph overview. Select Edit commit message, reword it to respect the conventional commit guidelines and press Update message.

Click Push on the top of the screen and select Force Push to bring the changes to the Pull Request.

我的分支与远程不同步

这意味着 oh-my-posh 的主分支包含你的分支没有的提交(可能是你的主分支或工作分支)。为了解决这个问题,我们需要执行变基操作(将 oh-my-posh 主分支的新提交放在你的新提交下方),这样拉取请求才能成功合并。

首先需要将 oh-my-posh 代码库添加为本地 Git 仓库的远程源。默认情况下,你的 fork 仓库是 oh-my-posh 的独立副本,在 GitHub 上有自己的远程源,与 oh-my-posh 原始代码库没有连接。Fork 和 Pull Request 是 GitHub 在 Git 功能基础上引入的特性,因此我们需要手动模拟这种情况。

添加远程源到本地 Git 仓库

Hover over Remote on the left-hand side, this will show a + button. Click it and select GitHub. There you have the ability to select jandedobbeleer/oh-my-posh and name it upstream. GitKraken will fetch the remote and you will see all branches underneath upstream as you do for your own branches. Right click upstream's main branch and select Rebase <branch> onto upstream/main.

Click Push on the top of the screen and select Force Push to bring the changes to the Pull Request.

将分支变基到上游主分支

Right click upstream's main branch and select Rebase <branch> onto upstream/main. Click Push on the top of the screen and select Force Push to bring the changes to the Pull Request.