Skip to content

Commit 3e9830d

Browse files
authored
Merge pull request libgit2#3822 from libgit2/ethomson/checkout_head_docs
documentation: improve docs for `checkout_head`
2 parents abb6f72 + b926648 commit 3e9830d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

include/git2/checkout.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,13 @@ GIT_EXTERN(int) git_checkout_init_options(
313313
* Updates files in the index and the working tree to match the content of
314314
* the commit pointed at by HEAD.
315315
*
316+
* Note that this is _not_ the correct mechanism used to switch branches;
317+
* do not change your `HEAD` and then call this method, that would leave
318+
* you with checkout conflicts since your working directory would then
319+
* appear to be dirty. Instead, checkout the target of the branch and
320+
* then update `HEAD` using `git_repository_set_head` to point to the
321+
* branch you checked out.
322+
*
316323
* @param repo repository to check out (must be non-bare)
317324
* @param opts specifies checkout options (may be NULL)
318325
* @return 0 on success, GIT_EUNBORNBRANCH if HEAD points to a non

0 commit comments

Comments
 (0)