Skip to content

Initialize and Upload a Git Project to GitHub (Windows)

This guide walks you through creating a new Git repository on your Windows workstation, adding files, and pushing them to GitHub.


Initializing and Publishing Your Project with Git and GitHub

Set up a new project directory, initialize it as a Git repository, and publish it to GitHub.

Prerequisites

  • Git installed (git --version to verify)
  • An active GitHub account

1. Create a Local Repository

Create and initialize your project folder:

mkdir my-project
cd my-project
git init
echo "# My Project" > README.md
git add README.md
git commit -m "Initial commit"

2. Create a Remote Repository on GitHub

  1. Log in to GitHub.
  2. Click New repository.
  3. Enter a repository name and description.
  4. Choose public or private, then click Create repository.
  5. Copy the HTTPS URL (e.g., https://github.com/yourusername/my-project.git).

Rename your local branch and add the remote origin:

git branch -M main
git remote add origin https://github.com/yourusername/my-project.git

4. Push Local Commits to GitHub

Push your commits and set the upstream reference:

git push -u origin main

Visit your GitHub repo page to confirm your README and initial commit.

5. Next Steps

  • Add a .gitignore file to exclude unnecessary files.
  • Create feature branches:
    git checkout -b feature/awesome-update
    
  • Use pull requests to review and merge changes.
  • Tag releases:
  git tag -a v1.0.0 -m "First stable release"