GitHub is a platform where we can share our code with the rest of the programming world.
To do this, we must first make an account on GitHub and create a repository.
Repo – short for repository – is a storage location for our projects. From hello world
to a fully-fledged documented project, we can push any project by first creating a repository on GitHub.
There is more than one way to create a repository in GitHub.
It is more common for programmers to do this using the Command Line Interface (CLI).
To create a repo from GitHub, you need a verified account from GitHub before you can follow the below steps as illustrated.
new repository
.We can describe our repository, including its purpose and its functionality.
If you want to make the repository private and not visible to others, select the private
radio button.
The check buttons include a README file for your project, including the technologies and basics of importing your project to another machine.
You can check all or none of the options, depending on your requirements.
Click on the Create Repository
button to create your first repo.
Now we can push any project on this repo.
We created our first repo from a GitHub account. Now let’s learn how to do it by using the git command line from your local machine.
The following commands must be entered to create a repository using this method:
git init
git add somefilename
git commit -m "initial commit"
git remote add origin https://github.com/username/new_repo
git push -u origin master
The git init
commands initializes your repository. You do not want to create an empty repository, so you must add git add somefile
in the procedure.
The commit
commands save your changes to a local repository on GitHub. Every time we make any changes in the code, we commit the code.
The remote
command states that this is a remote repository, and we have to add a path to it that shows its origin. The path is your repository URL shown in the below image.
And finally, we have to push
our repo to the master
branch. master
is the actual project file we work on.
Free Resources