6 git-update - update the current branch to the latest remote status
11 'git update' [options]
16 Incorporates changes from a remote repository into the current
19 `git update` runs `git fetch` and then tries to update the current branch to
20 the latest status. If you don't have any extra changes, the update operation is
21 straight-forward, but if you do have them, extra actions are necessary.
23 Assume the following history exists and the current branch is "master":
26 A---B---C origin/master
31 Then `git update` will merge in a fast-foward way up to the new master.
34 D---E---A---B---C master, origin/master
37 owever, a non-fast-foward case looks very different.
40 A---B---C origin/master
45 This divergence means 'master' cannot be fast-forwarded to 'origin/master' and
46 that is named a "non-fast-forward". By default `git update` will warn about
47 these situations, however, most likely you would want a merge, which you can
48 force with `git update --merge`. This will result in a new commit that combines
49 the tips of both branches ('C' and 'G'). See linkgit:git-merge[1] for more details.
59 You can choose to do a rebase instead by specifying the '--rebase' option,
60 which is slightly more complicated, but results in a cleaner history. In this
61 mode the commits that are not present in the remote branch are replayed on top
62 of it, which results in newer commits. See linkgit:git-rebase[1] for more
68 D---E---A---B---C origin/master
71 You should make sure you don't have any uncommitted changes before running
72 `git update`. It is generally best to get any local changes in working order
73 before pulling or stash them away with linkgit:git-stash[1].
78 By default `git update` will try to use the 'origin' remote and a branch with
79 the same name as the current branch. So if you are currently in the 'topic'
80 branch, `git update` will try to incorporate the changes from 'origin/topic'.
82 If you have configured an upstream tracking branch (e.g. git branch
83 --set-upstream-to), then that branch will be used instead of the default. To
84 find out the upstream of your current branch, you can run
85 `git name-rev @{upstream}`.
98 --[no-]recurse-submodules[=yes|on-demand|no]::
99 This option controls if new commits of all populated submodules should
100 be fetched too (see linkgit:git-config[1] and linkgit:gitmodules[5]).
101 That might be necessary to get the data needed for merging submodule
102 commits. Notice that the result of a merge will not be checked out in
103 the submodule, "git submodule update" has to be called afterwards to
104 bring the work tree up to date with the merge result.
107 --rebase[=false|true|preserve]::
108 When true, rebase the current branch on top of the remote
109 branch after fetching.
111 When preserve, also rebase the current branch on top of the upstream
112 branch, but pass `--preserve-merges` along to `git rebase` so that
113 locally created merge commits will not be flattened.
115 When false, merge the current branch into the upstream branch.
117 See `update.mode`, `branch.<name>.updatemode` and `branch.autosetuprebase` in
118 linkgit:git-config[1] if you want to make `git update` always use
122 This is a potentially _dangerous_ mode of operation.
123 It rewrites history, which does not bode well when you
124 published that history already. Do *not* use this option
125 unless you have read linkgit:git-rebase[1] carefully.
131 See `update.mode`, `branch.<name>.updatemode` in linkgit:git-config[1] if you want
132 to make `git update` always use `--merge`.
134 Options related to merging
135 ~~~~~~~~~~~~~~~~~~~~~~~~~~
138 include::merge-options.txt[]
139 include::merge-strategies.txt[]
143 Using --recurse-submodules can only fetch new commits in already checked
144 out submodules right now. When e.g. upstream added a new submodule in the
145 just fetched commits of the superproject the submodule itself can not be
146 fetched, making it impossible to check out that submodule later without
147 having to do a fetch again. This is expected to be fixed in a future Git
152 linkgit:git-fetch[1], linkgit:git-merge[1], linkgit:git-rebase[1], linkgit:git-config[1]
156 Part of the linkgit:git[1] suite