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