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

# Demo Explain Basic Repository Operations

> Step by step tutorial for creating, cloning, branching, editing, and pushing changes to a GitHub repository, with authentication tips using personal access tokens

In this lesson we'll walk through creating a GitHub repository in the web UI, adding files, creating a branch, cloning the repo locally, making changes on a feature branch, and pushing those changes back to GitHub. Each image below corresponds to a step in the workflow and is shown in the original sequence so you can follow along visually.

## 1. Create a new repository on GitHub

Open GitHub in your browser and create a new repository. Choose a clear repository name (for example, `block-buster`) and add an optional description describing what the project does. For discoverability choose `Public` if you want anyone to view the repository.

Initialize the repository with a `README.md` (so visitors immediately see project context), add a `.gitignore` (to exclude editor or OS-specific files, e.g., VS Code artifacts), and optionally choose a license.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/UUYFvHM79dCKO7ER/images/GitHub-Foundations-Certification/GitHub-Repositories/Demo-Explain-Basic-Repository-Operations/github-dashboard-repositories-beginners-playlist.jpg?fit=max&auto=format&n=UUYFvHM79dCKO7ER&q=85&s=2f1877dd2f9cee904f84429bf820aa8f" alt="The image shows a GitHub dashboard with repositories listed on the left and a section promoting a GitHub for Beginners YouTube playlist on the right. There are various options for creating issues, writing code, and managing repositories at the top." width="1920" height="1080" data-path="images/GitHub-Foundations-Certification/GitHub-Repositories/Demo-Explain-Basic-Repository-Operations/github-dashboard-repositories-beginners-playlist.jpg" />
</Frame>

When filling in repository details, the web UI guides you through the name, description, visibility, and initialization options.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/UUYFvHM79dCKO7ER/images/GitHub-Foundations-Certification/GitHub-Repositories/Demo-Explain-Basic-Repository-Operations/github-new-repository-interface.jpg?fit=max&auto=format&n=UUYFvHM79dCKO7ER&q=85&s=4df3d1a64f2812593bc80f803fdeb43d" alt="This image shows a GitHub interface for creating a new repository, with fields for the repository name, description, and visibility settings. The visibility option is highlighted, with a choice between &#x22;Public&#x22; and &#x22;Private.&#x22;" width="1920" height="1080" data-path="images/GitHub-Foundations-Certification/GitHub-Repositories/Demo-Explain-Basic-Repository-Operations/github-new-repository-interface.jpg" />
</Frame>

## 2. Add project files via the web UI (optional)

You can upload your initial project files directly from the GitHub UI: use Add files → Upload files. Common files for a simple web project include `index.html`, `script.js`, and `style.css`. Provide a short commit message (for example, `init`) and commit directly to `main` or create a new branch from the UI.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/UUYFvHM79dCKO7ER/images/GitHub-Foundations-Certification/GitHub-Repositories/Demo-Explain-Basic-Repository-Operations/github-file-upload-interface-repository.jpg?fit=max&auto=format&n=UUYFvHM79dCKO7ER&q=85&s=24664e87165ffaaca7ea2fd4688fa8d9" alt="The image shows a GitHub interface for uploading files to a repository, with fields for file selection and commit messages, and options for committing to a branch or creating a new branch." width="1920" height="1080" data-path="images/GitHub-Foundations-Certification/GitHub-Repositories/Demo-Explain-Basic-Repository-Operations/github-file-upload-interface-repository.jpg" />
</Frame>

## 3. Create a feature branch in the GitHub UI

Working on a branch keeps `main` stable. From the repository page you can create a feature branch (for example, `feature-1`) and continue development there.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/UUYFvHM79dCKO7ER/images/GitHub-Foundations-Certification/GitHub-Repositories/Demo-Explain-Basic-Repository-Operations/github-repo-block-buster-feature-1.jpg?fit=max&auto=format&n=UUYFvHM79dCKO7ER&q=85&s=1123f6ee6681650cf96c95fdadd46417" alt="The image shows a GitHub repository page for a project named &#x22;block-buster&#x22; with a menu open to create a new branch named &#x22;feature-1.&#x22; It features information about the project, including its description and commit history." width="1920" height="1080" data-path="images/GitHub-Foundations-Certification/GitHub-Repositories/Demo-Explain-Basic-Repository-Operations/github-repo-block-buster-feature-1.jpg" />
</Frame>

## 4. Clone the repository locally

On your machine, clone the repository to work locally. Copy the HTTPS clone URL from the GitHub repository page and run the commands below. This example creates a `~/github-repos` directory and clones `block-buster` into it:

```bash theme={null}
mkdir -p ~/github-repos
cd ~/github-repos
git clone https://github.com/sid-gh900/block-buster.git
cd block-buster
git branch --list
git branch --list -a
```

Example output after cloning:

```bash theme={null}
Cloning into 'block-buster'...
remote: Enumerating objects: 9, done.
remote: Counting objects: 100% (9/9), done.
remote: Compressing objects: 100% (9/9), done.
Receiving objects: 100% (9/9), 13.95 KiB | 714.00 KiB/s, done.
Resolving deltas: 100% (1/1), done.

# inside the repository
$ git branch --list
* main

$ git branch --list -a
* main
  remotes/origin/HEAD -> origin/main
  remotes/origin/feature-1
  remotes/origin/main
```

If a remote branch (`feature-1`) exists and you want it locally, create a local tracking branch.

```bash theme={null}
# If your Git auto-creates tracking branches:
git checkout feature-1

# or explicitly create a local branch that tracks the remote:
git checkout -b feature-1 origin/feature-1

# or with the modern command:
git switch --track origin/feature-1
```

## 5. Make changes locally and push to the feature branch

Open the project in your editor (for example, Visual Studio Code) and make changes to `README.md` or add new files/folders. The image below shows a README open while on a feature branch in VS Code.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/UUYFvHM79dCKO7ER/images/GitHub-Foundations-Certification/GitHub-Repositories/Demo-Explain-Basic-Repository-Operations/vscode-workspace-readme-block-buster.jpg?fit=max&auto=format&n=UUYFvHM79dCKO7ER&q=85&s=aa1adc026aee3aa9f919b479102fb524" alt="The image shows a Visual Studio Code workspace with a README.md file open, detailing a &#x22;Block Buster - Game&#x22; project using HTML, CSS, and JavaScript. There's also a terminal at the bottom displaying the current Git branch and repository information." width="1920" height="1080" data-path="images/GitHub-Foundations-Certification/GitHub-Repositories/Demo-Explain-Basic-Repository-Operations/vscode-workspace-readme-block-buster.jpg" />
</Frame>

When your edits are ready, stage, commit, and push them to the remote feature branch. You can use the editor's GUI or run these commands in the terminal:

```bash theme={null}
git add README.md
git commit -m "modified README file"
git push origin feature-1
```

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/UUYFvHM79dCKO7ER/images/GitHub-Foundations-Certification/GitHub-Repositories/Demo-Explain-Basic-Repository-Operations/vscode-workspace-readme-terminal-branch.jpg?fit=max&auto=format&n=UUYFvHM79dCKO7ER&q=85&s=765be74bbb9a59eea27601b512edda81" alt="The image shows a Visual Studio Code workspace with a project open, displaying a README.md file outlining features and technical details. A terminal at the bottom is ready for input, set on a feature branch." width="1920" height="1080" data-path="images/GitHub-Foundations-Certification/GitHub-Repositories/Demo-Explain-Basic-Repository-Operations/vscode-workspace-readme-terminal-branch.jpg" />
</Frame>

### Common Git troubleshooting (authentication / permissions)

If a push fails with a permission issue, you may see:

```bash theme={null}
$ git push origin feature-1
remote: Permission to sid-gh900/block-buster.git denied to alice-mcberry.
fatal: unable to access 'https://github.com/sid-gh900/block-buster.git/': The requested URL returned error: 403
```

A few diagnostic steps:

1. Check the currently configured remotes:
   ```bash theme={null}
   git remote -v
   ```

2. If credentials are cached and causing issues, make Git prompt for credentials by unsetting the credential helper (this may vary by OS):
   ```bash theme={null}
   git config --global --unset credential.helper
   ```
   Note: macOS Keychain, Windows Credential Manager, or other external helpers may store credentials outside Git; remove them via your OS credential manager if needed.

3. Optionally embed your username in the remote URL so Git prompts for a password for that user:
   ```bash theme={null}
   git remote set-url origin https://sid-gh900@github.com/sid-gh900/block-buster.git
   git remote get-url origin
   # origin  https://sid-gh900@github.com/sid-gh900/block-buster.git (fetch)
   ```

Important: GitHub no longer accepts account passwords for Git operations over HTTPS. Use a personal access token (PAT) instead.

<Callout icon="lightbulb" color="#1CB2FE">
  When pushing over HTTPS, provide a [personal access token (PAT)](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) as the password. Alternatively, configure an SSH key and use the SSH clone URL to avoid HTTPS-based token prompts.
</Callout>

## 6. Create and use a Personal Access Token (PAT)

To create a PAT: go to GitHub Settings → Developer settings → Personal access tokens (classic) or choose the newer fine‑grained tokens depending on your needs. For pushes you typically need `repo` scope (or repository-specific scopes for fine‑grained tokens). Set an expiration, generate the token, and copy it immediately — GitHub shows it only once.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/UUYFvHM79dCKO7ER/images/GitHub-Foundations-Certification/GitHub-Repositories/Demo-Explain-Basic-Repository-Operations/github-personal-access-token-creation.jpg?fit=max&auto=format&n=UUYFvHM79dCKO7ER&q=85&s=2b9fe56affd90607a2ae33921822486f" alt="The image shows a GitHub interface for creating a new personal access token (classic) with options for setting its expiration and permissions. Options for expiration include specific days or no expiration." width="1920" height="1080" data-path="images/GitHub-Foundations-Certification/GitHub-Repositories/Demo-Explain-Basic-Repository-Operations/github-personal-access-token-creation.jpg" />
</Frame>

When prompted for credentials during `git push`:

* Enter your GitHub username.
* Paste the PAT when asked for the password.

A successful push looks like:

```bash theme={null}
$ git push origin feature-1
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 20 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 2.38 MiB | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
To https://github.com/sid-gh900/block-buster.git
   abcdef1..1234567  feature-1 -> feature-1
```

If you need to view, edit, or revoke tokens later, go to Developer settings → Personal access tokens in your GitHub account.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/UUYFvHM79dCKO7ER/images/GitHub-Foundations-Certification/GitHub-Repositories/Demo-Explain-Basic-Repository-Operations/github-developer-settings-personal-access-token.jpg?fit=max&auto=format&n=UUYFvHM79dCKO7ER&q=85&s=abe0352cdd7971c0d52fec71e99b8ae8" alt="The image shows the GitHub Developer Settings page for personal access tokens, with an example token displayed for copying or deletion." width="1920" height="1080" data-path="images/GitHub-Foundations-Certification/GitHub-Repositories/Demo-Explain-Basic-Repository-Operations/github-developer-settings-personal-access-token.jpg" />
</Frame>

<Callout icon="warning" color="#FF6B6B">
  Never commit your personal access tokens, SSH private keys, or other secrets into a repository. Use environment variables, secret managers, or GitHub Secrets for CI workflows instead.
</Callout>

## 7. Confirm changes on GitHub

Back on GitHub you can browse the `feature-1` branch to confirm your pushed changes, including README updates, images, code blocks, and project structure.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/UUYFvHM79dCKO7ER/images/GitHub-Foundations-Certification/GitHub-Repositories/Demo-Explain-Basic-Repository-Operations/github-repo-block-buster-game.jpg?fit=max&auto=format&n=UUYFvHM79dCKO7ER&q=85&s=e6ef2c6f6743e189961cc663d16f9c98" alt="The image shows a GitHub repository page for a project called &#x22;Block Buster - Game.&#x22; It includes a README section with instructions for downloading and playing a brick breaker game built with HTML5, CSS, and JavaScript." width="1920" height="1080" data-path="images/GitHub-Foundations-Certification/GitHub-Repositories/Demo-Explain-Basic-Repository-Operations/github-repo-block-buster-game.jpg" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/UUYFvHM79dCKO7ER/images/GitHub-Foundations-Certification/GitHub-Repositories/Demo-Explain-Basic-Repository-Operations/github-readme-game-features-list.jpg?fit=max&auto=format&n=UUYFvHM79dCKO7ER&q=85&s=305aa9f38bd1bceeee56595b4ec77eaa" alt="The image shows a GitHub README section that lists features of a game, including core gameplay mechanics, power-ups, and technical features like responsive design and data persistence." width="1920" height="1080" data-path="images/GitHub-Foundations-Certification/GitHub-Repositories/Demo-Explain-Basic-Repository-Operations/github-readme-game-features-list.jpg" />
</Frame>

## Quick reference — common commands

| Action                              | Command / Example                                               |
| ----------------------------------- | --------------------------------------------------------------- |
| Clone a repo                        | `git clone https://github.com/<owner>/<repo>.git`               |
| List branches                       | `git branch --list`                                             |
| List remote branches                | `git branch -a`                                                 |
| Create local branch tracking remote | `git checkout -b feature-1 origin/feature-1`                    |
| Switch to branch (modern)           | `git switch feature-1` or `git switch --track origin/feature-1` |
| Stage & commit                      | `git add README.md` then `git commit -m "message"`              |
| Push branch                         | `git push origin feature-1`                                     |
| View remotes                        | `git remote -v`                                                 |

## Summary

This workflow demonstrates how to:

* Create a repository on GitHub (including `README.md` and `.gitignore`).
* Upload files via the web UI or work locally after cloning.
* Create and switch to feature branches.
* Clone repositories and manage branches locally.
* Resolve common authentication issues by using a Personal Access Token (PAT) for HTTPS pushes, or by using SSH keys.

This article focuses on the basic operations described above. It does not cover pull requests, merging `feature-1` into `main`, or repository access controls in depth. To invite collaborators (for code review or contributions) go to the repository Settings → Manage access and add reviewers or contributors (for example, `Siddharth` and `Alice McBury`).

Further reading:

* [GitHub Docs — Creating a repository](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository)
* [GitHub Docs — Creating a personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token)

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/github-foundation-certification/module/8933863d-4b81-4c80-90af-2f28f8519020/lesson/64cd2e1d-48ba-4a66-b56b-a734cbb54727" />
</CardGroup>
