- Go to GitHub and log in.
- Click the “+” icon in the top right corner and select “New repository”.
- Fill in the repository name, description (optional), and choose between public or private.
- Initialize the repository with a README if desired.
- Click “Create repository”.
-
Initialize Git in Your Project Directory:
- Open your terminal and navigate to your project directory:
cd /path/to/your/project
- Initialize a new Git repository:
git init
- Open your terminal and navigate to your project directory:
-
Add Remote Repository:
- Copy the URL of your GitHub repository (found on the repository page under the “Code” button).
- Add the remote repository:
git remote add origin https://github.com/yourusername/your-repository.git
-
First Commit and Push:
- Add your project files to the staging area:
git add .
- Commit your changes:
git commit -m "Initial commit"
- Change branch
git branch -M main
- Push your changes to GitHub:
git push -u origin main
- Add your project files to the staging area: