{"id":28665427,"url":"https://github.com/nothingmuch/git-snapshot","last_synced_at":"2025-11-04T02:04:19.434Z","repository":{"id":839004,"uuid":"561427","full_name":"nothingmuch/git-snapshot","owner":"nothingmuch","description":null,"archived":false,"fork":false,"pushed_at":"2010-03-15T03:42:43.000Z","size":94,"stargazers_count":19,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-24T04:20:36.245Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nothingmuch.png","metadata":{"files":{"readme":"README.markdown","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-03-14T02:23:27.000Z","updated_at":"2024-04-24T04:20:36.246Z","dependencies_parsed_at":"2022-08-16T11:05:23.202Z","dependency_job_id":null,"html_url":"https://github.com/nothingmuch/git-snapshot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nothingmuch/git-snapshot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nothingmuch%2Fgit-snapshot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nothingmuch%2Fgit-snapshot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nothingmuch%2Fgit-snapshot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nothingmuch%2Fgit-snapshot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nothingmuch","download_url":"https://codeload.github.com/nothingmuch/git-snapshot/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nothingmuch%2Fgit-snapshot/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259654360,"owners_count":22891005,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-13T13:38:35.202Z","updated_at":"2025-11-04T02:04:19.387Z","avatar_url":"https://github.com/nothingmuch.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# git snapshot\n\nThis command is provides a snapshotting mechanism for refs/workdirs.\n\n## Synopsis\n\nRoutinely run git snapshot to save undo points:\n\n\t% vim quxx.txt\n\t% git snapshot\n\t# ...\n\t% git add . \u0026\u0026 git commit -am \"new commit\"\n\t% git snapshot\n\nLater, if you need to recall any recorded information:\n\n\t% git log refs/snapshots/HEAD\n\t% git log refs/snapshots/refs/heads/master\n\t% git checkout refs/snapshots/refs/heads/master:quxx.txt\n\n## Rationale\n\nOften times I find myself sketching out projects without wanting to actually\nrecord a revision history yet.\n\nEven though the history has no organizational value I could run:\n\n\tgit add . \u0026\u0026 git commit -m \"$(date)\"\n\nevery once in a while in order to record an edit history, sort of like an\non-disk undo log.\n\n`git snapshot` provides something less messy than this ad-hoc approach, and\nsafer than simply not recording anything at all.\n\n## Behavior\n\nWhen invoked `git snapshot` will run `git snapshot-ref HEAD`, and if `HEAD` is\na symbolic ref, also `git snapshot-ref refs/heads/master` or whatever HEAD is\nreferring to.\n\n`git-snapshot-ref` starts by running `git snapshot-tree`, which reads the\ncurrent working tree into a temporary Git index file, uses `git write-tree` to\nrecord that data in the object database, and prints the sha1 of the recorded\ntree.\n\n`git-snapshot-ref` then checks if the previous snapshot (recorded in\n`refs/snapshots/$source_ref`, i.e. `refs/snapshots/HEAD`,\n`refs/snapshots/refs/heads/master`, ...) is up to date. If the tree has changed\nor new commits have been made on the ref, then a new commit is recorded into\nthe snapshots ref.\n\nIf you're working on a large patch, you can also snapshot an explicit ref:\n\n\tgit snapshot-ref topic_branch\n\nOnce you've created your commits, and then squashed and merged them you can:\ndelete the snapshot log for that branch:\n\n\tgit update-ref -d refs/snapshots/topic_branch\n\n## Usage\n\nBy routinely running `git snapshot` (for instance from within a crontab) you\nget a fully versioned history that is somewhat similar in usefulness to `git\nreflog`; if you made a mistake in recording your changes, or if you\naccidentally modified a file before comitting it, you can recall a previous\nversion from the snapshot history:\n\n\tgit log refs/snapshots/...\n\tgit checkout refs/snapshots/...:the/file/i/want.txt\n\n## With Spotlight\n\nOn MacOS X you can use the Finder's _Get Info_ dialogue to add a spotlight\ncomment or a label to project directories.\n\nThen you can use one of the following commands in your crontab to automatically\nsnapshot it:\n\n\t# snapshot every directory with 'git-snapshot' in its comment\n\tmdfind -0 \"kMDItemFinderComment == '*git-snapshot*'\" | xargs -0 -n 1 git-snapshot\n\n\t# snapshot every directory under ~/code that has the red label\n\tmdfind -0 -onlyin ~/code \"kMDItemFSLabel == 6\" | xargs -0 -n 1 git-snapshot\n\n## See Also\n\n- `git help rev-parse` for specifying time based revisions (e.g.\n  `refs/snapshots/HEAD@{yesterday}`)\n- `git commit --amend` in conjuction with `git reflog` can provide a similar\n  safety net.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnothingmuch%2Fgit-snapshot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnothingmuch%2Fgit-snapshot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnothingmuch%2Fgit-snapshot/lists"}