Merge branch 'ew/send-email'
[git/fastimport.git] / Documentation / git-rebase.txt
blob1b482abecdc2e953db1f29cb3c531f665ea8011c
1 git-rebase(1)
2 =============
4 NAME
5 ----
6 git-rebase - Rebase local commits to a new head
8 SYNOPSIS
9 --------
10 'git-rebase' [--onto <newbase>] <upstream> [<branch>]
12 'git-rebase' --continue
14 'git-rebase' --abort
16 DESCRIPTION
17 -----------
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.
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.
30 Note that if <branch> is not specified on the command line, the currently
31 checked out branch is used.
33 Assume the following history exists and the current branch is "topic":
35 ------------
36           A---B---C topic
37          /
38     D---E---F---G master
39 ------------
41 From this point, the result of either of the following commands:
44     git-rebase master
45     git-rebase master topic
47 would be:
49 ------------
50                   A'--B'--C' topic
51                  /
52     D---E---F---G master
53 ------------
55 While, starting from the same point, the result of either of the following
56 commands:
58     git-rebase --onto master~1 master
59     git-rebase --onto master~1 master topic
61 would be:
63 ------------
64               A'--B'--C' topic
65              /
66     D---E---F---G master
67 ------------
69 In case of conflict, git-rebase will stop at the first problematic commit
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
76     git update-index <filename>
79 After resolving the conflict manually and updating the index with the
80 desired resolution, you can continue the rebasing process with
83     git rebase --continue
86 Alternatively, you can undo the git-rebase with
89     git rebase --abort
91 OPTIONS
92 -------
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>.
98 <upstream>::
99         Upstream branch to compare against.
101 <branch>::
102         Working branch; defaults to HEAD.
104 --continue::
105         Restart the rebasing process after having resolved a merge conflict.
107 --abort::
108         Restore the original branch and abort the rebase operation.
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.
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.
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.
126 Author
127 ------
128 Written by Junio C Hamano <junkio@cox.net>
130 Documentation
131 --------------
132 Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
136 Part of the gitlink:git[7] suite