简体   繁体   English

如何始终使用git mergetool进行合并?

[英]How to always use git mergetool to merge?

I am managing a repo where people in my team often submit codes that should be discarded. 我正在管理一个存储库,在该存储库中,团队中的人们经常提交应丢弃的代码。 When I do a git pull, it automatically merge the files and it is annoying to go into each files to delete the codes. 当我执行git pull时,它会自动合并文件,进入每个文件以删除代码很烦人。 I use command line and gitkraken to manage the repo. 我使用命令行和gitkraken来管理仓库。 Is it possible to stop auto merge and require each pull with mergetool? 是否可以停止自动合并并要求使用mergetool进行每次拉动?

也许您可以在合并后仅使用git revert来撤消那些不需要其代码的提交?

I guess would be related to git workflows and how to manage a repo in a development team by defining various branches for dev , mainstream and etc. 我想这可能与git工作流程以及如何通过为devmainstream等定义各种分支来管理开发团队中的仓库有关。

You can read about it here . 你可以在这里阅读。

Basically, what development team do is creating subbranch from the stable branch before starting their development (let's call it dev-featureX ) and once development was completed, changes are pushed to the same branch on the remote server (in our case: origin/dev-featureX ). 基本上,开发团队要做的是在开始开发之前从稳定分支创建子分支(我们将其称为dev-featureX ),一旦开发完成,更改dev-featureX远程服务器上的同一分支(在我们的示例中为origin/dev-featureX )。 Repo maintainer (in our case means you) pull all the branches in its client: 回购维护者(在我们的情况下意味着您)拉动其客户中的所有分支机构:

git pull

checkout to recently published branch: 结帐至最近发布的分支:

git checkout dev-featureX

Review and audit the codes and changes and finally merge approved changes to the main branch (imagine in our case, dev branch): 审查并审核代码和更改,最后将批准的更改合并到主分支(在我们的情况下为dev分支):

git merge dev-featureX dev

Note that, the easiest workflow to manage called Centralized-workflow which has a similar approach to traditional VCS like SVN. 请注意,最易于管理Centralized-workflow称为Centralized-workflow ,它与SVN等传统VCS具有相似的方法。

Stop using git pull . 停止使用git pull All it does is run two other Git commands. 它所要做的就是运行另外两个Git命令。 If you run the two other commands yourself, you have more control. 如果您自己运行另外两个命令,则可以得到更多控制。

First, run git fetch to bring over the new code. 首先,运行git fetch带来新代码。

Then, run git merge --no-commit to merge without committing. 然后,运行git merge --no-commit合并而不提交。 You may now run additional commands. 您现在可以运行其他命令。 However, note that git mergetool assumes that anything Git merged by itself is correctly merged, and does not offer re-merging of these files. 但是,请注意, git mergetool假定任何自身合并的Git git mergetool正确合并,并且不提供这些文件的重新合并。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM