如何解决如何在git中合并与我的日常工作流程类似的分支?
我使用的是Windows 10,但可以访问Ubuntu 20 VM服务器(无桌面GUI)。我通过安装tortoisehg进行了安装,这也“礼貌”地安装了KDiff3进行合并。
我正在使用的git repo托管在github中。我正在使用Ubuntu服务器通过各种Unix文本编辑器来编辑工作目录文件。
我没用过git。我精通水银。假设我有一个名为beta
的分支,它从master
开始。我在回购开始后的dude.htm
中发现了一个错字。要在两个分支中修复它,请执行以下操作:
hg update master
# Open up my favorite GUI text editor and fix the typo. Save file
hg commit -m "Fix typo in dude"
在这里,我可以通过持续集成来构建我的项目,并确认拼写错误已得到修复。现在,我想将其合并到 beta
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的文件,但我这样做有些怀疑,因为我总是遇到围绕行尾(和其他)符号的问题。
如何执行git合并,如上面所述的hg合并?是否有像KDiff3这样的GUI,可以从Ubuntu命令行git merge命令运行?
解决方法
在git
命令中:从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,测试修复程序...
合并为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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。