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