git将功能分支重设为主分支

git将功能分支重设为主分支,git,github,version-control,gitlab,Git,Github,Version Control,Gitlab,我正在尝试将一个功能分支重定基址到主分支。在第7步及以后的步骤中,我将面临这个问题。您能否帮助确定git rebase的问题。即使在步骤7中解决了合并冲突之后,我仍然面临这个问题 参考: 1. 创建新分支:新建一个分支 修改文件。在新分支中添加新提交 修改文件。新分支中的其他提交 krishna@krishna-Lenovo-G50-70:~/r/testrebaseone$ git commit -m 'commit E' [new-branch-one 78b0680] commit E

我正在尝试将一个功能分支重定基址到主分支。在第7步及以后的步骤中,我将面临这个问题。您能否帮助确定git rebase的问题。即使在步骤7中解决了合并冲突之后,我仍然面临这个问题

参考: 1.

  • 创建新分支:新建一个分支
  • 修改文件。在新分支中添加新提交
  • 修改文件。新分支中的其他提交

    krishna@krishna-Lenovo-G50-70:~/r/testrebaseone$ git commit -m 'commit E'
    [new-branch-one 78b0680] commit E
     1 file changed, 2 insertions(+)
    
    krishna@krishna-Lenovo-G50-70:~/r/testrebaseone$ git commit -m 'commit f'
    [f-two 99210bc] commit f
     1 file changed, 2 insertions(+)
    
    krishna@krishna-Lenovo-G50-70:~/r/testrebaseone$ git commit -m 'commit g'
    [f-two 6ed028f] commit g
     1 file changed, 2 insertions(+)
    
  • 签出主分支
  • 从位于本地主分支上的远程主节点进行拉取

    krishna@krishna-Lenovo-G50-70:~/r/testrebaseone$ git pull origin master
    Username for 'https://gitlab.com': krishnagk
    Password for 'https://krishnagk@gitlab.com': 
    From https://gitlab.com/krishnagk/testrebaseone
     * branch            master     -> FETCH_HEAD
    Already up to date.
    
  • 创建新分支:f-2
  • 修改文件。在新分支中添加新提交

    krishna@krishna-Lenovo-G50-70:~/r/testrebaseone$ git commit -m 'commit E'
    [new-branch-one 78b0680] commit E
     1 file changed, 2 insertions(+)
    
    krishna@krishna-Lenovo-G50-70:~/r/testrebaseone$ git commit -m 'commit f'
    [f-two 99210bc] commit f
     1 file changed, 2 insertions(+)
    
    krishna@krishna-Lenovo-G50-70:~/r/testrebaseone$ git commit -m 'commit g'
    [f-two 6ed028f] commit g
     1 file changed, 2 insertions(+)
    
    修改文件。新分支中的其他提交

    krishna@krishna-Lenovo-G50-70:~/r/testrebaseone$ git commit -m 'commit E'
    [new-branch-one 78b0680] commit E
     1 file changed, 2 insertions(+)
    
    krishna@krishna-Lenovo-G50-70:~/r/testrebaseone$ git commit -m 'commit f'
    [f-two 99210bc] commit f
     1 file changed, 2 insertions(+)
    
    krishna@krishna-Lenovo-G50-70:~/r/testrebaseone$ git commit -m 'commit g'
    [f-two 6ed028f] commit g
     1 file changed, 2 insertions(+)
    
    将新分支推送到远程存储库

    krishna@krishna-Lenovo-G50-70:~/r/testrebaseone$ git push origin f-two
    Username for 'https://gitlab.com': krishnagk
    Password for 'https://krishnagk@gitlab.com': 
    Enumerating objects: 8, done.
    Counting objects: 100% (8/8), done.
    Delta compression using up to 4 threads
    Compressing objects: 100% (4/4), done.
    Writing objects: 100% (6/6), 505 bytes | 505.00 KiB/s, done.
    Total 6 (delta 1), reused 0 (delta 0)
    remote: 
    remote: To create a merge request for f-two, visit:
    remote:   https://gitlab.com/krishnagk/testrebaseone/-/merge_requests/new?merge_request%5Bsource_branch%5D=f-two
    remote: 
    To https://gitlab.com/krishnagk/testrebaseone.git
    * [new branch]      f-two -> f-two
    
  • 创建合并请求以将f-2分支合并到主分支中
  • 请求将f-2合并到主机中

    17分钟前由Krishna Kurtakoti合并(2021年6月2日上午8:09GMT+0530)17分钟前 这些更改与044f2ae0合并到master中

    成功合并后,签出本地主分支并从远程主分支进行拉取

    krishna@krishna-Lenovo-G50-70:~/r/testrebaseone$ git checkout master
    Already on 'master'
    Your branch is up to date with 'origin/master'.
    krishna@krishna-Lenovo-G50-70:~/r/testrebaseone$ git pull origin master
    Username for 'https://gitlab.com': krishnagk
    Password for 'https://krishnagk@gitlab.com': 
    From https://gitlab.com/krishnagk/testrebaseone
     * branch            master     -> FETCH_HEAD
    Already up to date.
    
  • 签出分支新分支1
  • 当我想在分支上执行rebase主控时,这一步出现了问题 新分行一号
  • @多谢。我尝试了你的建议,结果如下:

    krishna@krishna-Lenovo-G50-70:~/r/testrebaseone$ git status
    rebase in progress; onto 044f2ae
    You are currently rebasing branch 'new-branch-one' on '044f2ae'.
      (all conflicts fixed: run "git rebase --continue")
    
    nothing to commit, working tree clean
    

    伙计,你的问题太详细了。 看起来它可以归结为您在步骤7中遇到的合并冲突

    您已经在两个分支中修改了
    todo
    文件,git不知道选择哪个版本,或者它应该部分地从一个分支中选择更改并添加另一个分支的更改,以及如何处理公共部分?Git不知道如何回答这类问题,所以让您自己去理解该怎么做

    所以,您可以在步骤7
    git status
    之后键入底线,您将看到它正在进行重定基址,并且存在需要解决的冲突

    您可以解决文件中的冲突(我通常在IDE中解决,比如JetBrains,因为它们提供了良好的UI),但您可以使用任何其他IDE,也可以自己解决

    在任何情况下,一旦您解决了冲突并获得了想要保留的版本,您就可以键入
    git add.
    (或者
    git add todo
    ,如果您想具体说明的话),然后键入
    git rebase--continue
    (双连字符)
    GIT将继续重设基础,并使其达到“干净状态”的程度。

    步骤太多。请将您的问题简化为更简单的问题。它告诉您要做什么:
    git-rebase--继续
    我会注意到,细节太多总比不够好。:-)我用两个连字符替换了你的em破折号(以防有人想剪切和粘贴它),但在你的附加说明中留下了。
    krishna@krishna-Lenovo-G50-70:~/r/testrebaseone$ git commit -m 'rebase'
    [detached HEAD c83a6ff] rebase
     1 file changed, 2 insertions(+)
    krishna@krishna-Lenovo-G50-70:~/r/testrebaseone$ git rebase --continue
    Applying: commit D
    No changes - did you forget to use 'git add'?
    If there is nothing left to stage, chances are that something else
    already introduced the same changes; you might want to skip this patch.
    
    krishna@krishna-Lenovo-G50-70:~/r/testrebaseone$ git status
    rebase in progress; onto 044f2ae
    You are currently rebasing branch 'new-branch-one' on '044f2ae'.
      (all conflicts fixed: run "git rebase --continue")
    
    nothing to commit, working tree clean
    
    krishna@krishna-Lenovo-G50-70:~/r/testrebaseone$ git rebase --continue
    Applying: commit D
    No changes - did you forget to use 'git add'?
    If there is nothing left to stage, chances are that something else
    already introduced the same changes; you might want to skip this patch.
    Resolve all conflicts manually, mark them as resolved with
    "git add/rm <conflicted_files>", then run "git rebase --continue".
    You can instead skip this commit: run "git rebase --skip".
    To abort and get back to the state before "git rebase", run "git rebase --abort".
    
    krishna@krishna-Lenovo-G50-70:~/r/testrebaseone$ git rebase --skip
    Applying: commit E
    Using index info to reconstruct a base tree...
    M   todo
    Falling back to patching base and 3-way merge...
    Auto-merging todo