Skip to content

Commit 70c48c3

Browse files
authored
Merge pull request #1149 from vcfxb/venus/1148
docs(#1148): Add note regarding potentially confusing behavior of `git_checkout_head`.
2 parents cb57f5c + 2f3a8b9 commit 70c48c3

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/repo.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2065,6 +2065,13 @@ impl Repository {
20652065

20662066
/// Updates files in the index and the working tree to match the content of
20672067
/// the commit pointed at by HEAD.
2068+
///
2069+
/// Note that this is _not_ the correct mechanism used to switch branches;
2070+
/// do not change your `HEAD` and then call this method, that would leave
2071+
/// you with checkout conflicts since your working directory would then
2072+
/// appear to be dirty. Instead, checkout the target of the branch and
2073+
/// then update `HEAD` using [`Repository::set_head`] to point to the
2074+
/// branch you checked out.
20682075
pub fn checkout_head(&self, opts: Option<&mut CheckoutBuilder<'_>>) -> Result<(), Error> {
20692076
unsafe {
20702077
let mut raw_opts = mem::zeroed();

0 commit comments

Comments
 (0)