Add --continue and --abort options to git-rebase.
git rebase [--onto <newbase>] <upstream> [<branch>] git rebase --continue git rebase --abort Add "--continue" to restart the rebase process after manually resolving conflicts. The user is warned if there are still differences between the index and the working files. Add "--abort" to restore the original branch, and remove the .dotest working files. Some minor additions to the git-rebase documentation. [jc: fix that applies to the maintenance track has been dealt with separately.] Signed-off-by: Junio C Hamano <junkio@cox.net>
sean committed
Apr 26, 2006 at 10:49 UTC
031321c654de3c19de45b2dacbdc990b5a694e34
2 files changed
+101
-37
Documentation/git-rebase.txt
+63
-13
@@ -3,38 +3,54 @@ git-rebase(1)
3
4
NAME
5
----
6
-git-rebase - Rebase local commits to new upstream head
6
+git-rebase - Rebase local commits to a new head
7
8
SYNOPSIS
9
--------
10
'git-rebase' [--onto <newbase>] <upstream> [<branch>]
11
12
+'git-rebase' --continue
13
+
14
+'git-rebase' --abort
15
+
16
DESCRIPTION
17
-----------
14
-git-rebase applies to <upstream> (or optionally to <newbase>) commits
15
-from <branch> that do not appear in <upstream>. When <branch> is not
16
-specified it defaults to the current branch (HEAD).
18
+git-rebase replaces <branch> with a new branch of the same name. When
19
+the --onto option is provided the new branch starts out with a HEAD equal
20
+to <newbase>, otherwise it is equal to <upstream>. It then attempts to
21
+create a new commit for each commit from the original <branch> that does
22
+not exist in the <upstream> branch.
23
18
-When git-rebase is complete, <branch> will be updated to point to the
19
-newly created line of commit objects, so the previous line will not be
20
-accessible unless there are other references to it already.
24
+It is possible that a merge failure will prevent this process from being
25
+completely automatic. You will have to resolve any such merge failure
26
+and run `git rebase --continue`. If you can not resolve the merge
27
+failure, running `git rebase --abort` will restore the original <branch>
28
+and remove the working files found in the .dotest directory.
29
+
30
+Note that if <branch> is not specified on the command line, the currently
31
+checked out branch is used.
32
33
Assume the following history exists and the current branch is "topic":
34
35
+------------
36
A---B---C topic
37
/
38
D---E---F---G master
39
+------------
40
41
From this point, the result of either of the following commands:
42
43
+
44
git-rebase master
45
git-rebase master topic
46
47
would be:
48
49
+------------
50
A'--B'--C' topic
51
/
52
D---E---F---G master
53
+------------
54
55
While, starting from the same point, the result of either of the following
56
commands:
@@ -44,21 +60,33 @@ commands:
60
61
would be:
62
63
+------------
64
A'--B'--C' topic
65
/
66
D---E---F---G master
67
+------------
68
69
In case of conflict, git-rebase will stop at the first problematic commit
52
-and leave conflict markers in the tree. After resolving the conflict manually
53
-and updating the index with the desired resolution, you can continue the
54
-rebasing process with
70
+and leave conflict markers in the tree. You can use git diff to locate
71
+the markers (<<<<<<) and make edits to resolve the conflict. For each
72
+file you edit, you need to tell git that the conflict has been resolved,
73
+typically this would be done with
74
+
75
+
76
+ git update-index <filename>
77
+
78
+
79
+After resolving the conflict manually and updating the index with the
80
+desired resolution, you can continue the rebasing process with
81
+
82
+
83
+ git rebase --continue
84
56
- git am --resolved --3way
85
86
Alternatively, you can undo the git-rebase with
87
60
- git reset --hard ORIG_HEAD
61
- rm -r .dotest
88
+
89
+ git rebase --abort
90
91
OPTIONS
92
-------
@@ -73,6 +101,28 @@ OPTIONS
101
<branch>::
102
Working branch; defaults to HEAD.
103
104
+--continue::
105
+ Restart the rebasing process after having resolved a merge conflict.
106
+
107
+--abort::
108
+ Restore the original branch and abort the rebase operation.
109
+
110
+NOTES
111
+-----
112
+When you rebase a branch, you are changing its history in a way that
113
+will cause problems for anyone who already has a copy of the branch
114
+in their repository and tries to pull updates from you. You should
115
+understand the implications of using 'git rebase' on a repository that
116
+you share.
117
+
118
+When the git rebase command is run, it will first execute a "pre-rebase"
119
+hook if one exists. You can use this hook to do sanity checks and
120
+reject the rebase if it isn't appropriate. Please see the template
121
+pre-rebase hook script for an example.
122
+
123
+You must be in the top directory of your project to start (or continue)
124
+a rebase. Upon completion, <branch> will be the current branch.
125
+
126
Author
127
------
128
Written by Junio C Hamano <junkio@cox.net>
git-rebase.sh
+38
-24
@@ -4,37 +4,51 @@
4
#
5
6
USAGE='[--onto <newbase>] <upstream> [<branch>]'
7
-LONG_USAGE='git-rebase applies to <upstream> (or optionally to <newbase>) commits
8
-from <branch> that do not appear in <upstream>. When <branch> is not
9
-specified it defaults to the current branch (HEAD).
10
-
11
-When git-rebase is complete, <branch> will be updated to point to the
12
-newly created line of commit objects, so the previous line will not be
13
-accessible unless there are other references to it already.
14
-
15
-Assuming the following history:
16
-
17
- A---B---C topic
18
- /
19
- D---E---F---G master
20
-
21
-The result of the following command:
22
-
23
- git-rebase --onto master~1 master topic
24
-
25
- would be:
26
-
27
- A'\''--B'\''--C'\'' topic
28
- /
29
- D---E---F---G master
7
+LONG_USAGE='git-rebase replaces <branch> with a new branch of the
8
+same name. When the --onto option is provided the new branch starts
9
+out with a HEAD equal to <newbase>, otherwise it is equal to <upstream>
10
+It then attempts to create a new commit for each commit from the original
11
+<branch> that does not exist in the <upstream> branch.
12
+
13
+It is possible that a merge failure will prevent this process from being
14
+completely automatic. You will have to resolve any such merge failure
15
+and run git-rebase --continue. If you can not resolve the merge failure,
16
+running git-rebase --abort will restore the original <branch> and remove
17
+the working files found in the .dotest directory.
18
+
19
+Note that if <branch> is not specified on the command line, the
20
+currently checked out branch is used. You must be in the top
21
+directory of your project to start (or continue) a rebase.
22
+
23
+Example: git-rebase master~1 topic
24
+
25
+ A---B---C topic A'\''--B'\''--C'\'' topic
26
+ / --> /
27
+ D---E---F---G master D---E---F---G master
28
'
31
-
29
. git-sh-setup
30
31
unset newbase
32
while case "$#" in 0) break ;; esac
33
do
34
case "$1" in
35
+ --continue)
36
+ diff=$(git-diff-files)
37
+ case "$diff" in
38
+ ?*) echo "You must edit all merge conflicts and then"
39
+ echo "mark them as resolved using git update-index"
40
+ exit 1
41
+ ;;
42
+ esac
43
+ git am --resolved --3way
44
+ exit
45
+ ;;
46
+ --abort)
47
+ [ -d .dotest ] || die "No rebase in progress?"
48
+ git reset --hard ORIG_HEAD
49
+ rm -r .dotest
50
+ exit
51
+ ;;
52
--onto)
53
test 2 -le "$#" || usage
54
newbase="$2"