Create New Crate

Chester Wyke November 02, 2023 Updated: April 15, 2025 #rust

Patterned on: New Repo Creation

Notes

Instructions

  1. Create empty repo in cloud

  2. Create folder on local machine with same name (same name is recommended not required)

  3. Open a command prompt in the folder and initialize the crate

    cargo init --lib
    
  4. Make initial commit

  5. Add remote repo connection (Can be copied from github)

    git remote add origin git@github.com:wykies/REPO_NAME.git
    
  6. Push branch to remote (Can be done from vscode UI) and set current branch as a tracking branch (-u sets current brach to tracking)

    git push -u origin main
    
  7. Copy in and link to template (for updates). To see more explanation of these steps see CI instructions.

    git remote add template git@github.com:c-git/rust-crate-template.git
    git fetch template
    git merge --allow-unrelated template/main
    
  8. Resolve merge conflict

    git checkout template/main -- .gitignore
    git checkout template/main -- Cargo.toml
    git checkout template/main -- src/lib.rs
    
  9. Restore crate name (was lost during merge).

  10. Add CI.