[英]Why do I need a local master branch?
Our team is using git for quite some time, but still this thing escapes me.我们的团队使用 git 已经有一段时间了,但是这件事还是让我措手不及。 I'm constantly getting conflicts with my files that have been merged earlier, and vacuous diffs with the files modified by other team members.我经常与之前合并的文件发生冲突,并且与其他团队成员修改的文件之间存在空白差异。 Usually, it happens in my branch merged earlier, and it is quite laborious to resolve these issues to get clean mergereq...通常,它发生在我较早合并的分支中,解决这些问题以获得干净的合并是相当费力的...
Therefore, I'm trying to simplify the development process as much as possible, to have it nuisance-error-resilient as SVN.因此,我试图尽可能地简化开发过程,让它像 SVN 一样具有抗干扰能力。 Can I have one local branch sourced from origin/master which I merge every week?我可以每周合并一个来自 origin/master 的本地分支吗? What do I need to do to keep it not stale, is egit pull just enough?我需要做什么才能让它不陈旧,egit pull 就够了吗? Or do I have to dance through或者我必须跳舞通过
git checkout master
git pull
git checkout my_branch
git merge master
every time?每次? The first command obviously creates local master, which answers my question in the title, but why egit pull wouldn't be just enough?第一个命令显然创建了本地 master,它回答了我在标题中的问题,但为什么 egit pull 还不够?
Git doesn't know that commits have been made to master at origin unless you update the local repo somehow--usually either with a fetch
or pull
. Git 不知道在原始位置已经向 master 提交了,除非您以某种方式更新本地存储库——通常是使用fetch
或pull
。 This means that if you just merge your local copy of master you may be merging an obsolete head state, which can cause problems when you try to push.这意味着,如果您只是合并 master 的本地副本,您可能正在合并一个过时的 head state,这可能会在您尝试推送时导致问题。
You don't need a local master branch.您不需要本地主分支。 You can avoid that hassle by merging the remote branch:您可以通过合并远程分支来避免这种麻烦:
git merge origin/master
I like this workflow which uses a combination of reset --hard
and rebase
:我喜欢这个工作流程,它结合了reset --hard
和rebase
:
git checkout master
git fetch --all
git reset --hard origin/master
git checkout feature
git rebase master
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.