Как я могу изменить, на какой ветке основана моя текущая ветка? - PullRequest
0 голосов
/ 24 ноября 2011

Вот ситуация, у меня есть три ветви, master, fix#1 и fix#2, где оба последние два исправляют одну конкретную ошибку.

Проблема в том, что я основал fix#2 на fix#1, вместо того, чтобы переходить от мастера, так что это выглядит примерно так

fix#2
|
fix#1
|
master

вместо

fix#1  fix#2
|     / 
master 

Есть ли простой способ, как я могуудалить все коммиты fix#1 из ветви fix#2 (на самом деле это один коммит)?

1 Ответ

2 голосов
/ 24 ноября 2011
git rebase --onto master fix1 fix2

Но прежде чем сделать это, убедитесь, что вы понимаете, что должно произойти и все последствия.

git rebase -h вывод:

Usage: git rebase [--interactive | -i] [-v] [--force-rebase | -f] [--no-ff] [--onto <newbase>] (<upstream>|--root) [<branch>] [--quiet | -q]

git-rebase replaces <branch> with a new branch of the
same name.  When the --onto option is provided the new branch starts
out with a HEAD equal to <newbase>, otherwise it is equal to <upstream>
It then attempts to create a new commit for each commit from the original
<branch> that does not exist in the <upstream> branch.

It is possible that a merge failure will prevent this process from being
completely automatic.  You will have to resolve any such merge failure
and run git rebase --continue.  Another option is to bypass the commit
that caused the merge failure with git rebase --skip.  To restore the
original <branch> and remove the .git/rebase-apply working files, use the
command git rebase --abort instead.

Note that if <branch> is not specified on the command line, the
currently checked out branch is used.

Example:       git-rebase master~1 topic

        A---B---C topic                   A'--B'--C' topic
       /                   -->           /
  D---E---F---G master          D---E---F---G master
...