Sitemap

Pushing local repo to GitHub

1 min readDec 28, 2023

--

To push an existing folder with code to GitHub, you can follow these general steps using the command line. Make sure you have Git installed on your machine and that you have created a repository on GitHub:

  1. Navigate to your project folder: Open a terminal or command prompt and use the cd command to navigate to your project folder.
cd /path/to/your/project/folder

2. Initialize a Git repository: If your project folder is not already a Git repository, you need to initialize it.

git init

3. Add your files to the staging area: Use the following command to add all the files in your project folder to the staging area.

git add .

4. If you want to add specific files, replace . with the filenames.

Get Daniel Karanja’s stories in your inbox

Join Medium for free to get updates from this writer.

5. Commit the changes: Commit the files to the local repository with a meaningful commit message.

git commit -m "Initial commit"

6. Create a new repository on GitHub: Go to GitHub and create a new repository. Follow the instructions provided on GitHub to create an empty repository.

7. Add the GitHub repository as a remote: Add the GitHub repository as a remote to your local repository.

git remote add origin https://github.com/username/repository.git

8. Replace https://github.com/username/repository.git with the URL of your GitHub repository.

9. Push your code to GitHub: Push your code to the GitHub repository.

git push -u origin master

10. If you’re working with a branch other than master, replace master with your branch name.

--

--

Daniel Karanja
Daniel Karanja

Written by Daniel Karanja

Fullstack Developer |Python|Flask|Django| Restful APIs | Javascript| React| TypeScript