> For the complete documentation index, see [llms.txt](https://reactjs.koida.tech/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://reactjs.koida.tech/git-and-githubs/git-commands.md).

# Git Commands

## **Git Commands - Working Locally and Remotely:**

1. ## How to upload files and folders to GitHub: GitHub for beginners

{% embed url="<https://youtu.be/tlu5e0TxSzo?si=ZAjX7KD8bnqRm9Hg>" %}

1. **Git Commands**

* Initialize repository: `$git init`
* Stage files: `$git add filename`
* Commit changes: `$git commit -m "commit message"`
* Check status: `$git status`
* Clone repo: `$git clone [repo_url]`
* Push changes: `$git push origin main`

*Activity:* Follow these detailed steps to create a local repository, add and commit a file, and push it to GitHub:

2. **Initialize a Local Repository:**
   * Open Terminal (Mac/Linux) or Command Prompt (Windows).
   * Create a new directory: `$mkdir`` `<mark style="color:orange;">`GitExample`</mark>` ``&& cd`` `<mark style="color:orange;">`GitExample`</mark>
   * Initialize Git in this directory: `$git init`
3. **Create and Add a File:**
   * Create a text file: `$echo "This is my first Git file" >`` `<mark style="color:orange;">`example.txt`</mark>
   * Stage the file for commit: `$git add`` `<mark style="color:orange;">`example.txt`</mark>
   * Verify the staged file: `$git status`
4. **Commit the File Locally:**
   * **Commit** the file with a message: `$git commit -m "Initial commit with example.txt"`
   * Confirm the commit: `$git log`
5. **Push to GitHub:**
   * Go to [GitHub](https://github.com/) and create a new repository (e.g., `GitExampleRepo`). Do NOT initialize it with a README.
   * Copy the repository URL from GitHub (choose HTTPS).
   * **Link** your local repository to GitHub:
     * `$git remote add origin https://github.com/YourUsername/GitExampleRepo.git`
   * **Push** your commit to GitHub:
     * `$git push -u origin main`
6. **Verify on GitHub:**
   * Go to your GitHub repository and refresh the page to see your `example.txt` file.

By completing this activity, you will understand how to initialize a local Git repository, commit changes, and push them to a remote repository on GitHub
