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

Examples: Checkout Commit #323

Closed
marwan-at-work opened this issue Apr 5, 2017 · 2 comments
Closed

Examples: Checkout Commit #323

marwan-at-work opened this issue Apr 5, 2017 · 2 comments

Comments

@marwan-at-work
Copy link
Contributor

marwan-at-work commented Apr 5, 2017

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)
@smola
Copy link
Collaborator

smola commented Apr 6, 2017

@marwan-at-work We'll be glad to accept a PR adding a checkout example.

@marwan-at-work
Copy link
Contributor Author

#331
cc: @smola

@mcuadros mcuadros closed this as completed Apr 8, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants