GitHub basically is a for-profit company owned by Microsoft, which hosts Git repositories online. It helps users share their git repository online, with other users, or access it remotely. You can also host a public repository for free on Github. In this article, we will be explaining the procedure to push our local folders, projects, files, etc to a GitHub repository in a simple and elegant way.
Step by Step Process
First of all, make sure to install Git on your computer. Now, head toward that folder that you want to push there on GitHub. Then, follow the following steps.
Step 1. Open Git Bash in that particular folder. Type git init (this will make that folder a repository)
Step 2: Type git add . (this will add all files to the repository)
Step 3. Type git commit -m “Initial commit msg” (all files now in the repository)
Step 4. Type git status (you will get a msg, “On branch master nothing to commit, working tree clean” this shows your local repository is finally created)
These are the steps that are used to make a local repository, now to push the same to a GitHub repository we use the following steps-
Step 1. Open your GitHub profile and create a New Repository. Copy the SSH Key of that created repository.
Step 2. Open Git Bash in that particular folder that you want to push. Type git remote add origin PASTE_SSH_KEY_OF_CREATED_REPO. Then type git push origin master –force (type ‘main’ in place of the ‘master’ if your default branch is master). Please refer to the following picture (if needed):
Now, refresh your Github page, you will be able to see your committed folders/files there.
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses
are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!