Upload local directory codes to a new GitHub repository

To upload your local directory and codes to a fresh GitHub repository, follow these steps:

  1. Initialize a Local Git Repository: Navigate to your local directory using the terminal or command prompt and run:

    git init

  1. Add All Files to the Local Repository: Still in the terminal or command prompt, run:

git add .

  1. Commit the Changes: Commit the changes you've made with a message describing the initial commit:

git commit -m "Initial commit"

  1. Link the Local Repository to the GitHub Repository: Replace YOUR_GITHUB_REPO_URL with the URL of your fresh GitHub repository (you can find this URL on the main page of your GitHub repo, it usually looks like https://github.com/username/repo-name.git):

git remote add origin YOUR_GITHUB_REPO_URL

  1. Push the Changes to GitHub: Push your local commits to the GitHub repository:

git push -u origin master

Note: If you're using the default branch name other than master (e.g., main), replace master with the appropriate branch name in the command above.

  1. Verify: Go to your GitHub repository in your web browser and refresh the page. You should now see your local directory and codes uploaded to the repository.

Remember, every time you make changes to your local files and want to update them on GitHub, you'll need to repeat the git add, git commit, and git push steps.

Last updated

Was this helpful?