Git rebase为一个分支创建了几天 [英] Git rebase for a branch created days back

查看:135
本文介绍了Git rebase为一个分支创建了几天的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这种情况下,我需要帮助理解git rebase。我检查了一个10天前创建的分支。我检出使用

I need help in understanding git rebase for this situation. I checked out a branch created by some one 10 days back. I checked out using

git checkout -b <some name> origin/branchname

(我只是用不同的名字来识别它)

(I just used different name to identify it)

结帐后,如果我在这个退出的分支做rebase,

After checkout, if I do rebase by being in this checked out branch,

git rebase origin/master

它显示了一些错误,例如
1)尾随空格 - 在尝试了我在网上找到的这个命令后,我仍然看到警告。

It shows some errors like 1) Trailing whitespace - I read about this but even after trying this command that I found online, i still see the warnings.

 git config core.whitespace nowarn



2)自动合并
CONFLICT(添加/添加):合并冲突...
这些文件位于主分支中,但内容稍微修改结帐分支。那么我应该如何解决这个问题?如果这是解决问题的方法,我无权直接更改主内容。这些文件应该有来自这个结帐分支的内容,以便测试可以正常工作,因为它与此有关。请澄清我..

2) Auto-merging CONFLICT (add/add): Merge conflict in... these files are in master branch but the content is modified a little bit in the checkout branch. So how should I fix this? I don't have authority to change anything in master directly if that's the way to fix it. These files should have the content from this checkout branch so that the testing will work fine as it's related to that..please clarify me..

问候

推荐答案

伙计们已经回答了关于空格的问题,但没有涉及到问题的rebase部分。以下是你发生重大事件时发生的事情:

Guys have pretty much answered the question about whitespaces but didn't touch the rebase part of the question. Here is what's happening when you rebase:

先检查某个分支,然后说:

first your checking out to some branch, then you say:

git rebase master

这意味着您想重新绑定当前HEAD(您的主题分支)放在主人面前。
Git正在回顾主题分支的历史和主分支的历史记录,并发现它们都是第一个共同祖先的提交。此提交将成为您的主题分支的旧基础。然后,它会在您的分支中接受所有发生的提交,并按照当前主控之上的顺序重新应用它们。有时可能会发生冲突,然后rebase进程停止并等待您的解决方案。所以你必须通过编辑文件来手动解决它们,然后将它们标记为 git add conflicted_file
解决完成后,您必须说 git rebase --continue

This means that you would like to rebase the current HEAD (your topic branch) onto master. Git is going back in history of your topic branch and in history of master branch and finds a commit that is a first common ancestor for both of them. This commit will be an old base for your topic branch. Then it takes all commits that happened since then in your branch and "reapplies" them in the order of appearance on top of the current master. Sometimes conflict can happen, then the rebase process stops and waits for your resolution. So you have have to manually resolve them by editing files and then marking them as resolved by git add conflicted_file When this is done you will have to say git rebase --continue

现在您不需要更改master分支中的文件 - 更改发生在您的主题分支和冲突解决方案记录在您的主题分支中。

Now you're NOT changing files in master branch by doing that - the changes are happening in your topic branch and conflicts resolution are recorded in your topic branch.

希望有所帮助。

这篇关于Git rebase为一个分支创建了几天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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