dolt icon indicating copy to clipboard operation
dolt copied to clipboard

Support `dolt checkout` by commit hash or tag name

Open addisonklinke opened this issue 3 years ago • 4 comments
trafficstars

This functionality is present in git but not yet with dolt, i.e.

dolt checkout 39mg263d
dolt checkout myTag

addisonklinke avatar Dec 06 '21 20:12 addisonklinke

You can do hash but not short hash.

On Mon, Dec 6, 2021 at 12:53 PM Addison Klinke @.***> wrote:

This functionality is present in git but not yet with dolt, i.e.

dolt checkout 39mg263d dolt checkout myTag

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/dolthub/dolt/issues/2464, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJAR3GDJCXLL4XOLADGDT3UPUPF3ANCNFSM5JPS3ZNA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

timsehn avatar Dec 06 '21 21:12 timsehn

@addisonklinke Dolt doesn't support "detached head" currently, so it's not possible to checkout commits that are not referenced by a branch.

Could you let us know a bit more about your use case for checking out tags and commit hashes? If you want to inspect the data at a given hash you can use Dolt's AS OF syntax:

SELECT FROM myTable AS OF "39mg263d"

andy-wm-arthur avatar Feb 14 '22 22:02 andy-wm-arthur

@andrew-wm-arthur I would plan to checkout tags and/or commit hashes in an ML scenario where I want to train on a particular dataset version (or a commit that a colleague used). As a Python-oriented engineer, I find it more natural to do this from the CLI or Python API with dolt checkout rather than going into SQL and using AS OF

From the updated docs it looks like detached head mode is supported now. If so, does that provide all the core features needed to complete this request?

addisonklinke avatar Mar 11 '22 17:03 addisonklinke

Detached HEAD on the CLI is not something we plan on supporting in the near future. In SQL mode, we support detached heads.

timsehn avatar Aug 30 '22 21:08 timsehn

@timsehn is this still something thats not planned to be supported? I agree with @addisonklinke that it would be useful to checkout a commit hash or tag from a detached head to simplify the logic in ML training pipelines.

Additionally, it's not clear how to reference Releases created on DoltHub in a local Dolt repo. You can see the full hash of the release on DoltHub, but these aren't loaded as tags or anything in a local checkout.

radao avatar Jan 24 '23 12:01 radao

@timsehn is this still something thats not planned to be supported? I agree with @addisonklinke that it would be useful to checkout a commit hash or tag from a detached head to simplify the logic in ML training pipelines.

This is planned. I don't think I ever said it was not planned. We just have not got around to it.

Additionally, it's not clear how to reference Releases created on DoltHub in a local Dolt repo. You can see the full hash of the release on DoltHub, but these aren't loaded as tags or anything in a local checkout.

So releases show up as tags locally. Here's a workflow to get access to a tag without detached head. You just make a branch at the reference indicated by the tag.

PS C:\Users\timse\dolthub\dolt> dolt clone dolthub/us-jails
cloning https://doltremoteapi.dolthub.com/dolthub/us-jails
PS C:\Users\timse\dolthub\dolt> cd us-jails
PS C:\Users\timse\dolthub\dolt\us-jails> dolt tag
        _migrationtest
PS C:\Users\timse\dolthub\dolt\us-jails> dolt checkout -b release-branch _migrationtest
Switched to branch 'release-branch'
PS C:\Users\timse\dolthub\dolt\us-jails> dolt tag -v
_migrationtest  i3f3orlfmbjgqnst90c8r96jps7tdtv9
Tagger: andy <[email protected]>
Date:   Fri Jul 29 08:27:37 -0700 2022

        savepoint for migration testing

PS C:\Users\timse\dolthub\dolt\us-jails> dolt branch -va
  main                                                  i3f3orlfmbjgqnst90c8r96jps7tdtv9
* release-branch                                        i3f3orlfmbjgqnst90c8r96jps7tdtv9
  remotes/origin/main                                   i3f3orlfmbjgqnst90c8r96jps7tdtv9
  remotes/origin/spacelove/docs-1654809848              5unofrovlp90drn0uh13louv5551tk95
  remotes/origin/spacelove/workspace-1650463967         405hm744g48scb9cp778ul1uld0sm448
  remotes/origin/spacelove/workspace-1650464366         1clf17r2n0rcllcttaof2rfngse61cjc

timsehn avatar Jan 24 '23 16:01 timsehn

@timsehn is this still something thats not planned to be supported? I agree with @addisonklinke that it would be useful to checkout a commit hash or tag from a detached head to simplify the logic in ML training pipelines.

This is planned. I don't think I ever said it was not planned. We just have not got around to it.

Understood, thanks!

Additionally, it's not clear how to reference Releases created on DoltHub in a local Dolt repo. You can see the full hash of the release on DoltHub, but these aren't loaded as tags or anything in a local checkout.

So releases show up as tags locally. Here's a workflow to get access to a tag without detached head. You just make a branch at the reference indicated by the tag.

PS C:\Users\timse\dolthub\dolt> dolt clone dolthub/us-jails
cloning https://doltremoteapi.dolthub.com/dolthub/us-jails
PS C:\Users\timse\dolthub\dolt> cd us-jails
PS C:\Users\timse\dolthub\dolt\us-jails> dolt tag
        _migrationtest
PS C:\Users\timse\dolthub\dolt\us-jails> dolt checkout -b release-branch _migrationtest
Switched to branch 'release-branch'
PS C:\Users\timse\dolthub\dolt\us-jails> dolt tag -v
_migrationtest  i3f3orlfmbjgqnst90c8r96jps7tdtv9
Tagger: andy <[email protected]>
Date:   Fri Jul 29 08:27:37 -0700 2022

        savepoint for migration testing

PS C:\Users\timse\dolthub\dolt\us-jails> dolt branch -va
  main                                                  i3f3orlfmbjgqnst90c8r96jps7tdtv9
* release-branch                                        i3f3orlfmbjgqnst90c8r96jps7tdtv9
  remotes/origin/main                                   i3f3orlfmbjgqnst90c8r96jps7tdtv9
  remotes/origin/spacelove/docs-1654809848              5unofrovlp90drn0uh13louv5551tk95
  remotes/origin/spacelove/workspace-1650463967         405hm744g48scb9cp778ul1uld0sm448
  remotes/origin/spacelove/workspace-1650464366         1clf17r2n0rcllcttaof2rfngse61cjc

Works for me, thanks for the example!

radao avatar Jan 25 '23 16:01 radao

+1 also bumped into this


I found a workaround

SELECT p.* FROM `companies/tag_start_36c7c702-185f-4f4b-a700-12c7f1f943b0`.company_profile p  limit 100;

-- or
USE `companies/tag_start_36c7c702-185f-4f4b-a700-12c7f1f943b0`;
SELECT t.*
FROM companies.company_profile t
LIMIT 501;

nkonev avatar Mar 20 '23 13:03 nkonev

This might be easier to do now that we have dolt stash.

https://github.com/dolthub/dolt/issues/573

timsehn avatar Apr 28 '23 22:04 timsehn