Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Examples: Checkout Commit #323

@marwan-at-work

Description

@marwan-at-work

I think it would be great to add as many examples to the repo as possible, given that workflows are different. i.e.:

git cli: git checkout ae200dcc6592716c757372cf01825f21a6b6xxxx
go-git, sudo, : repo.Worktree().Checkout(plumbing.NewHash("ae200dcc6592716c757372cf01825f21a6b6xxxx")

Although this might be trivial to git-pros, I think it's really good to include common scenarios like this one. I'd love to submit a quick pr for it. Here's a simple example:

repo, err := git.PlainClone("/tmp/foo", false, &git.CloneOptions{
  URL: "https://github.com/src-d/go-git.git",
  Progress: os.Stdout,
})
CheckIfError(err)

wt, err := repo.Worktree()
CheckIfError(err)

commitRef := plumbing.NewHash("ae200dcc6592716c757372cf01825f21a6b6xxxx")
err = wt.Checkout(commitRef)
CheckIfError(err)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions