注:我使用的是 Windows 10,但我确实可以访问 Ubuntu 20 VM 服务器(无桌面 GUI)。我通过安装 tortoisehg 安装了 mercurial这也是“礼貌”安装KDiff3用于 merge 。
我正在使用的 git repo 托管在 github 中。我正在使用 Ubuntu 服务器使用各种 Unix 文本编辑器来编辑工作目录文件。
我没怎么用过 git。我更精通mercurial。假设我有一个名为 beta
的分支从 master
开始.我在 dude.htm
中发现了一个错字自 repo 开始以来就一直存在。要在两个分支中修复它,我执行以下操作:
hg update master
# Open up my favorite GUI text editor and fix the typo. Save file
hg commit -m "Fix typo in dude"
在这里,我可能会通过持续集成构建我的项目并验证拼写错误是否已修复。现在我想把它 merge 到 测试版 hg update beta
hg merge master
# here TortiseHg will ask me how I want to handle file conflicts
# and bring up KDiff3 to assist me with merging
hg commit -m "merge master > beta"
这是一个持续多年的坚实过程。我希望能够用这个 git repo 做同样的事情。我希望能够在我的 Windows 机器上编辑这个 git repo 的文件,但我对此有点怀疑,因为我总是遇到围绕行尾(和其他)符号的问题。我怎样才能像我上面描述的 hg merge 那样执行 git merge ?是否有像 KDiff3 这样的 GUI 可以通过 Ubuntu 命令行 git merge 命令工作?
最佳答案
至于git
命令 go :从 cli 中,您将运行
git checkout master
# fix the typo ...
# one change from Mercurial : in git you have to explicitly add the files
# in the staging area (also called 'index') before committing :
git add path/to/dude.htm
# where you explicitly add the files in
git commit -m "Fix typo in dude" # or just 'git commit', then type the commit
# message in the editor that opens
git add -u
:添加暂存区中已跟踪的所有文件您可以在提交前查看内容
git add -A
: 将磁盘中的所有文件添加到 运行 CI,测试修复...
merge 到
beta
:git checkout beta
git merge -m "merge master > beta" master
# if the merge triggers merge conflict :
git status # will highlight the conflicting files
git mergetool # will open your mergetool of choice (eg: kdiff3), once for each
# conflicting file
# once you have fixed the conflicts, run :
git commit
关于git - 如何在 git 中 merge 类似于我的 mercurial 工作流程的分支?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63528005/