]> git.ipfire.org Git - thirdparty/git.git/blame - Documentation/git-rebase.txt
Merge branch 'fix'
[thirdparty/git.git] / Documentation / git-rebase.txt
CommitLineData
215a7ad1
JH
1git-rebase(1)
2=============
7fc9d69f
JH
3
4NAME
5----
031321c6 6git-rebase - Rebase local commits to a new head
7fc9d69f
JH
7
8SYNOPSIS
9--------
69a60af5 10'git-rebase' [--onto <newbase>] <upstream> [<branch>]
7fc9d69f 11
031321c6
SE
12'git-rebase' --continue
13
14'git-rebase' --abort
15
7fc9d69f
JH
16DESCRIPTION
17-----------
031321c6
SE
18git-rebase replaces <branch> with a new branch of the same name. When
19the --onto option is provided the new branch starts out with a HEAD equal
20to <newbase>, otherwise it is equal to <upstream>. It then attempts to
21create a new commit for each commit from the original <branch> that does
22not exist in the <upstream> branch.
69a60af5 23
031321c6
SE
24It is possible that a merge failure will prevent this process from being
25completely automatic. You will have to resolve any such merge failure
26and run `git rebase --continue`. If you can not resolve the merge
27failure, running `git rebase --abort` will restore the original <branch>
28and remove the working files found in the .dotest directory.
29
30Note that if <branch> is not specified on the command line, the currently
31checked out branch is used.
69a60af5
CW
32
33Assume the following history exists and the current branch is "topic":
34
031321c6 35------------
69a60af5
CW
36 A---B---C topic
37 /
38 D---E---F---G master
031321c6 39------------
69a60af5 40
228382ae 41From this point, the result of either of the following commands:
69a60af5 42
031321c6 43
69a60af5
CW
44 git-rebase master
45 git-rebase master topic
46
47would be:
48
031321c6 49------------
69a60af5
CW
50 A'--B'--C' topic
51 /
52 D---E---F---G master
031321c6 53------------
69a60af5 54
228382ae 55While, starting from the same point, the result of either of the following
69a60af5
CW
56commands:
57
58 git-rebase --onto master~1 master
59 git-rebase --onto master~1 master topic
60
61would be:
62
031321c6 63------------
69a60af5
CW
64 A'--B'--C' topic
65 /
66 D---E---F---G master
031321c6 67------------
7fc9d69f 68
8978d043 69In case of conflict, git-rebase will stop at the first problematic commit
031321c6
SE
70and leave conflict markers in the tree. You can use git diff to locate
71the markers (<<<<<<) and make edits to resolve the conflict. For each
72file you edit, you need to tell git that the conflict has been resolved,
73typically this would be done with
74
75
76 git update-index <filename>
77
78
79After resolving the conflict manually and updating the index with the
80desired resolution, you can continue the rebasing process with
81
82
83 git rebase --continue
8978d043 84
8978d043
BF
85
86Alternatively, you can undo the git-rebase with
87
031321c6
SE
88
89 git rebase --abort
8978d043 90
7fc9d69f
JH
91OPTIONS
92-------
69a60af5
CW
93<newbase>::
94 Starting point at which to create the new commits. If the
95 --onto option is not specified, the starting point is
96 <upstream>.
97
52a22d1e
LAS
98<upstream>::
99 Upstream branch to compare against.
7fc9d69f 100
228382ae 101<branch>::
52a22d1e 102 Working branch; defaults to HEAD.
7fc9d69f 103
031321c6
SE
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
110NOTES
111-----
112When you rebase a branch, you are changing its history in a way that
113will cause problems for anyone who already has a copy of the branch
114in their repository and tries to pull updates from you. You should
115understand the implications of using 'git rebase' on a repository that
116you share.
117
118When the git rebase command is run, it will first execute a "pre-rebase"
119hook if one exists. You can use this hook to do sanity checks and
120reject the rebase if it isn't appropriate. Please see the template
121pre-rebase hook script for an example.
122
123You must be in the top directory of your project to start (or continue)
124a rebase. Upon completion, <branch> will be the current branch.
125
7fc9d69f
JH
126Author
127------
128Written by Junio C Hamano <junkio@cox.net>
129
130Documentation
131--------------
132Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
133
134GIT
135---
a7154e91 136Part of the gitlink:git[7] suite
7fc9d69f 137