Create a new repo

This is an example of how you can create a new Git repository on your workstation and then add it to GitHub

This was written based on a Git installation on Windows

This will create a new working directory on your workstation, initialize it for use with Git, add the files to Git, and lastly upload it all to GitHub.

Create a new directory on your computer where you want to store your project files.

mkdir my-project

Change directory to the new directory

cd my-project

Initialize the new empty repo

git init

Create a readme file

echo "# My Project" > README.md

Add the README file to the repository

git add README.md

Commit the changes to the Git repository. This will create a new commit with the changes you’ve made and a message describing the changes.

git commit -m "Initial commit"

Create a new repository on GitHub Go to the GitHub website and create a new repository for your project. Click on the “New” button on the top left corner of the page, give your repository a name, and then click the “Create repository” button. Once created, copy the HTTPS URL for the repository.

Connect the local repository to the remote repository using the following command. Replace “yourusername” with your GitHub username and “myproject” with the name of the repository you just created.

git remote add origin https://github.com/yourusername/myproject.git

This will push your changes to the “master” branch of the remote repository.

git push -u origin master
Last modified July 21, 2024: update (e2ae86c)