解决GIT中的冲突或避免冲突? [英] Conflict resolution or conflict avoidance in GIT?

查看:179
本文介绍了解决GIT中的冲突或避免冲突?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:几个人打算与GIT合作吗?是像SVN中一样通常进行update-commit还是默认使用merge?合并时,谁应该显示为合并提交的作者?

Questions: How are several people meant to work with GIT? Is update-commit usual as in SVN or is merge the default? When merging, who should appear as the author of the merging commit?

很多背景信息:我正在与另一个人在LaTeX上写论文,我们正在使用GIT进行版本控制.

A lot of background information: I am writing a paper on LaTeX with another guy and we are using GIT for the version control.

从一开始,我们就决定我们俩都将在master分支上工作,因为无论如何我们只有两个人.

From the start we decided we both would work on the master branch, because we are anyway only two people.

我已经做了很多提交.然后,他对旧版本进行了提交,并将我的最新版本与最新版本合并(提交之后).使用图片更容易看到:

I've done a number of commits. Then he did a commit over an old version and merged my last version and the most recent one (after his commit). This is easier to see with a picture:

对我来说,以这种方式进行合并很奇怪,如果我没记错的话,他应该先拉然后提交,那么合并应该在两个不同的分支之间进行.

To me it's weird to make the merge that way, if I'm not mistaken he should have pulled first and then committed, merge should be done between two different branches.

最奇怪的是,我的提交在任何时候都不会被删除,但是内容在最新提交中显示为新内容,而他作为作者出现.这看起来像个错误,但说实话我真的不明白这里发生了什么.

Weirdest of everything, my commits are not deleted at any point, but the contents appear as new in the latest commit and he appears as the author. This looks like a bug, but to say the truth I don't really understand what is going on here.

所以问题是:

那是个错误吗?

我们应该使用分支来单独工作吗?如果他无论如何都不将其提交到服务器,我可能会忽略他的提交.

Should we be using branches to work separately? I could be ignoring his commits if he doesn't push them to the server anyway.

他是否正确使用了系统,还是应该像在SVN中一样在提交之前进行拉动(更新->提交)?

Did he use the system properly or should he have done a pull before committing as in SVN (update -> commit)?

最后,我做了一个分支,一个提交和一个合并(尚未出现在图片中),并且可能会再次发生同一件事,因为现在主服务器已更新,而他可能会忽略这些更新,提交,然后合并为作者.

Last, I did a branch, a commit and a merge (that's not in the picture, yet), and probably the same thing is going to happen again because now the master is updated and he is probably going to ignore those updates, commit, then merge as the author.

这对我来说并不正确,但我不知道这是否正确.

That doesn't look right to me, but I don't know whether it is right or not.

IMHO :应该以更新提交的方式,在将更新推送到共享存储库之前,在本地进行合并.

IMHO: merge should be done locally, before pushing the updates to the shared repository, as in an update-commit fashion.

推荐答案

我们应该使用分支来单独工作吗?

Should we be using branches to work separately?

是:他应该做一个 git pull --rebase (对于尚未推送的分支),在推送其更改之前,此时您已经可以将其分支合并为简单的快进合并.
另请参见合并与重新设置

Yes: he should have done a git pull --rebase (for a branch not yet pushed), before pushing his changes, at which point you would have been able to merge his branch as a simple fast-forward merge.
See also merge vs. rebase and a similar blog post.

(摘自 Git是你的朋友而不是敌人Vol.4:变基础)

一般来说,是的,在推送之前在本地合并.

More generally, yes, merge locally before pushing.

这篇关于解决GIT中的冲突或避免冲突?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆