If you haven't already, sign up for a GitHub account at github.com. It's free for public repositories.
- Once logged in, click on the "+" icon in the top right corner and select "New repository".
- Choose a name for your repository. Make it descriptive and relevant to your project.
- Optionally, write a short description of your project.
- Decide whether you want the repository to be public or private.
- Initialize the repository with a README file if you want to start with one.
- Click "Create repository".
-
Install Git on your computer if you haven't already. You can download it from git-scm.com.
-
Open a terminal or command prompt.
-
Configure Git with your name and email address:
git config --global user.name "Your Name" git config --global user.email "[email protected]"
-
Go to your newly created repository on GitHub.
-
Click on the green "Code" button and copy the URL.
-
In your terminal or command prompt, navigate to the directory where you want to store your project.
-
Clone the repository using the following command:
git clone <repository_url>
- Place your project files into the directory you cloned the repository into.
- In the terminal or command prompt, navigate to your project directory.
-
Add your files to the staging area:
git add .
This command adds all files in the current directory and its subdirectories. If you want to add specific files, replace . with the file names.
-
Commit your changes:
git commit -m "Initial commit"
Replace "Initial commit" with a meaningful commit message describing your changes.
-
Push your changes to GitHub:
git push origin main
This command pushes your changes to the "master" branch of your GitHub repository. If you're working on a different branch, replace "master" with the name of your branch.
- Go back to your GitHub repository page and refresh it. You should see your project files listed there.
Congratulations! You've successfully created a repository and pushed your project to GitHub.