> ## Documentation Index
> Fetch the complete documentation index at: https://fastapi2day.codewithsiva.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Clone and Create Your Own GitHub Repositories

> Learn how to download any GitHub project to your machine and publish your own Python projects to GitHub for backup, sharing, and portfolio building.

There are two things you'll do constantly with Git and GitHub: cloning projects that other people have built, and publishing your own. Cloning lets you grab any open-source AI tool or example and run it locally within seconds. Creating and pushing your own repository puts your work online, gives you a permanent backup, and builds the public portfolio that employers and collaborators will look at. Both operations are simpler than they sound.

## Cloning a repository

Cloning means downloading a complete project — including all its history — from GitHub to your computer.

<Tip>
  **Skip the `cd` command entirely:**

  * **macOS** — Right-click a folder in Finder → **Services** → **New Terminal at Folder**
  * **Windows** — Right-click a folder in Explorer → **Open in Terminal** (or Shift + right-click → **Open PowerShell window here**)

  This opens the terminal already pointing at that folder.
</Tip>

<Tabs>
  <Tab title="HTTPS (Recommended)">
    ```bash theme={null}
    # Navigate to where you want the project
    cd ~/Documents       # macOS
    cd C:\Users\YourName\Documents  # Windows

    # Clone the repository
    git clone https://github.com/openai/openai-quickstart-python.git

    # Enter the project folder
    cd openai-quickstart-python

    # Open in VS Code
    code .
    ```
  </Tab>

  <Tab title="SSH">
    ```bash theme={null}
    # Navigate to where you want the project
    cd ~/Documents       # macOS
    cd C:\Users\YourName\Documents  # Windows

    # Clone using the SSH URL
    git clone git@github.com:openai/openai-quickstart-python.git

    # Enter the project folder
    cd openai-quickstart-python

    # Open in VS Code
    code .
    ```
  </Tab>
</Tabs>

<Note>
  **If `code .` doesn't work**, you need to register the `code` command first:

  **macOS:** Open VS Code → press `Cmd + Shift + P` → type **Shell Command: Install 'code' command in PATH** → press Enter → restart your terminal.

  **Windows:** During VS Code installation, make sure **Add to PATH** is checked. If you missed it, reinstall VS Code and check that option, or right-click the project folder and choose **Open with Code**.
</Note>

When cloning finishes, Git has downloaded all files and all history for that project. You can now run it, modify it, and learn from it freely.

<Tip>
  Clone projects into a consistent location. A `projects/` or `repos/` folder inside your Documents directory keeps everything organized.
</Tip>

## Creating your own repository

Let's publish your `python-for-ai` project to GitHub so it's backed up and shareable.

<Warning>
  **Before pushing to GitHub, create a `.gitignore` file.** Without it, Git may try to upload your `.venv` folder, which can be multiple gigabytes — and the push will likely fail or take forever.
</Warning>

### Step 1: Create a .gitignore file

Create a file named `.gitignore` at the root of your project with the following contents:

```text theme={null}
# .gitignore — tells Git what NOT to track
.venv/
.env
__pycache__/
*.pyc
.DS_Store
```

### Step 2: Create the repository on GitHub

<Steps>
  <Step title="Open GitHub">
    Go to [github.com](https://github.com) and click the green **New** button (or **+** → **New repository**).
  </Step>

  <Step title="Fill in the details">
    * **Repository name:** `python-for-ai`
    * **Description:** *Learning Python for AI development*
    * **Visibility:** Private for now (you can change it later)
    * **Do not** add a README, .gitignore, or license — your local project already has its own files
  </Step>

  <Step title="Click Create repository">
    GitHub will show you the commands to connect your local project.
  </Step>
</Steps>

### Step 3: Connect your local project and push

<Tabs>
  <Tab title="HTTPS (Recommended)">
    ```bash theme={null}
    # Navigate to your project folder
    cd ~/Documents/python-for-ai       # macOS
    cd C:\Users\YourName\Documents\python-for-ai  # Windows

    # Initialize Git
    git init

    # Stage all files
    git add .

    # Create your first commit
    git commit -m "Initial commit"

    # Rename the branch to main
    git branch -M main

    # Connect to GitHub (replace YOUR-USERNAME)
    git remote add origin https://github.com/YOUR-USERNAME/python-for-ai.git

    # Push your code
    git push -u origin main
    ```
  </Tab>

  <Tab title="SSH">
    ```bash theme={null}
    # Navigate to your project folder
    cd ~/Documents/python-for-ai       # macOS
    cd C:\Users\YourName\Documents\python-for-ai  # Windows

    # Initialize Git
    git init

    # Stage all files
    git add .

    # Create your first commit
    git commit -m "Initial commit"

    # Rename the branch to main
    git branch -M main

    # Connect to GitHub via SSH (replace YOUR-USERNAME)
    git remote add origin git@github.com:YOUR-USERNAME/python-for-ai.git

    # Push your code
    git push -u origin main
    ```
  </Tab>
</Tabs>

<Note>
  If prompted during the push, enter your GitHub username and your personal access token (not your password) as the credential.
</Note>

## The daily workflow

Once your project is on GitHub, your everyday routine is just three commands:

```bash theme={null}
# After making changes to your code...

git add .
git commit -m "Add new feature"
git push
```

That covers 90% of everything you'll do with Git.

## Common tasks

<AccordionGroup>
  <Accordion title="Clone with the VS Code UI">
    1. Press `Ctrl / Cmd + Shift + P`
    2. Type **Git: Clone**
    3. Paste the repository URL
    4. Choose where to save it
    5. VS Code opens the project automatically
  </Accordion>

  <Accordion title="Private vs public repositories">
    * **Private** — Only you (and anyone you invite) can see it. Good for learning projects.
    * **Public** — Anyone can see it. Good for portfolio work.

    You can change a repository's visibility at any time in its **Settings** tab on GitHub.
  </Accordion>

  <Accordion title="What belongs in .gitignore">
    ```text theme={null}
    .venv/          # Virtual environment — can be gigabytes
    .env            # Secrets and API keys — never commit these
    __pycache__/    # Python bytecode cache
    *.pyc           # Compiled Python files
    .DS_Store       # macOS metadata files
    ```
  </Accordion>
</AccordionGroup>

## Practice exercise

Try this before moving on:

1. Clone any Python project on GitHub that interests you
2. Create a new repository for one of your practice scripts
3. Make a small change, commit it, and push it

## What's next?

VS Code has a built-in visual interface for all of these Git operations. Let's explore how to use it without typing a single terminal command.

<Card title="Git in VS Code" icon="code" href="/tools/git/vscode-git">
  Use Git with clicks instead of commands
</Card>
