Push Folder to GitHub: Step-by-Step Guide
Pushing a folder to a GitHub repository is a straightforward process that allows you to save your local work on the cloud and collaborate with others. Here's a step-by-step guide to help you achieve this.
Before we begin, ensure you have Git installed on your computer. If not, you can download it from the official Git website. Also, create or choose a repository on GitHub where you want to push your folder.
Setting Up Git on Your Local Machine
First, we need to initialize Git in your local folder and link it to your GitHub account.
Open your terminal or command prompt, navigate to your folder, and run the following commands:
Initialize Git
This command tells Git to start tracking changes in your folder.
git init
Add and Commit Changes
Add your files to Git and make an initial commit with a descriptive message.
git add .git commit -m "Initial commit"
Linking Your Local Repository to GitHub
Now, let's connect your local repository to the GitHub repository you created earlier.
First, copy the repository URL from your GitHub repo page.
Add Remote Repository
Use the following command to add the GitHub repository as a remote.
git remote add origin <repository-url>
Push Changes to GitHub
Now, you can push your local changes to the GitHub repository using the command below.
git push -u origin main
That's it! Your folder is now pushed to your GitHub repository. You can view your files online on GitHub and collaborate with others. Happy coding!