Add files to a new Git Repository

Navigate to the location of the files to add:

git init

Add the remote repository:

git remote add origin <your-git-repo-url>

Note: If your Git repository already has files (like a README), you might need to pull first:

git pull origin master --allow-unrelated-histories

Then you can add and push your changes.

Add all existing files:

git add .

Create your first commit:

git commit -m "Initial commit"

Push to the remote repository:

git push -u origin master

Leave a Reply