# git help / faq

## commits vs versions
- You do not need to name every commit.
- Each commit already has a unique ID (hash).
- You can tag commits later to turn them into named versions.

## versions via tags
- Use tags to name versions:
  - `git tag v1`
  - `git tag v2`
  - `git tag backup-before-change`
- You can tag the current commit:
  - `git tag v1`
- Or tag an older commit:
  - `git tag v3 <commit-id>`

## restoring versions
- Restore entire repo to a version:
  - `git checkout v1`
- Restore a single file to a version:
  - `git checkout v1 -- path/to/file`
- Restore a file to previous commit:
  - `git checkout HEAD~1 -- filename`
- Restore a file to any commit:
  - `git checkout <commit-id> -- filename`

## listing versions and refs
- List tags (versions):
  - `git tag`
- Show all refs (branches, tags, HEAD):
  - `git show-ref`
- Show commit history:
  - `git log --oneline`

## diffing versions
- Working vs last commit:
  - `git diff`
- Staged vs last commit:
  - `git diff --cached`
- Version vs version:
  - `git diff v1 v2`
- File between versions:
  - `git diff v1 v2 -- filename`

## workflow summary
1. Work and commit normally.
2. When you reach a milestone, create a tag (version).
3. Later, restore repo or file to that tag.
4. Use diffs to compare versions.
5. Use installer/menu to automate tagging, restoring, and diffing.

