Skip to content

Commit d228210

Browse files
committed
Clarify checkout strategies
1 parent 8de22d5 commit d228210

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

docs/guides/101-samples/index.md

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,19 +1235,14 @@ The defaults won't be useful outside of a small number of cases.
12351235
The best example of this is `checkout_strategy`; the default value does nothing to the work tree.
12361236
So if you want your checkout to check files out, choose an appropriate strategy.
12371237
1238-
```c
1239-
git_checkout_opts opts = GIT_CHECKOUT_OPTS_INIT;
1240-
1241-
/* This is kind of like the command-line default */
1242-
opts.checkout_strategy = GIT_CHECKOUT_SAFE_CREATE;
1243-
/* This is kind of like the -f flag */
1244-
opts.checkout_strategy = GIT_CHECKOUT_FORCE;
1245-
```
1246-
1247-
(
1248-
[`git_checkout_opts`](http://libgit2.github.com/libgit2/#HEAD/type/git_checkout_opts),
1249-
[checkout header](https://github.com/libgit2/libgit2/blob/HEAD/include/git2/checkout.h#files)
1250-
)
1238+
* `NONE` is the equivalent of a dry run; no files will be checked out.
1239+
* `SAFE` is similar to `git checkout`; unmodified files are updated, and modified files are left alone.
1240+
If a file was present in the old HEAD but is missing, it's considered deleted, and won't be created.
1241+
* `SAFE_CREATE` is similar to `git checkout-index`, or what happens after a clone.
1242+
Unmodified files are updated, and missing files are created, but files with modifications are left alone.
1243+
* `FORCE` is similar to `git checkout --force`; all modifications are overwritten, and all missing files are created.
1244+
1245+
Take a look at the [checkout header](https://github.com/libgit2/libgit2/blob/HEAD/include/git2/checkout.h#files) for extensive explanation of the checkout flags.
12511246
12521247
<h3 id="checkout_simple">Simple</h3>
12531248

0 commit comments

Comments
 (0)