GitHub - Creating First Repo
3 min read
So, we have learned Basics of:
Time to move on and create our first repository on GitHub.
Creating First Repository on GitHub
Navigate to Repositories and click on New
Fill out basic info:
These two are compulsory:
- Repository Name
- Selection of Public and Private
Public Repository is seen by everyone where as Private Repository is only visible to you.
Once you are done, click on Create Repository:
Options in Creating Repository
Generally you are provided with three options.
Option 1 is used when you want to begin from scratch
Option 2 means that you are already working and just want to push the project on GitHub
Option 3 means to import a repository from somewhere else.
Create New Repository in CLI
You just need to enter the following commands as shown in option 1 in Git Bash.
Most of the commands have already been studied in our article where we got out basics of Git straight.
Lets rewind them a bit..
echo "# test-repo" >> README.mdThis creates
README.mdfile in the folder/directory you are present in and save
"# test-repo"as its contents in the file.
git initThis initializes the git repository in folder/directory you are present int.
git add README.mdREADME.md file which was created as a result of first command is now added to Staging Area
git commit -m "first commit"
commits the changes with the message
git branch -M mainThis
creates a branchcalled as
main. Note: We are always working in a branch; default branch is main.
So far, we have done stuff that we already knew. Time to move on to the remote commands.
git remote add origin https://github.com/shameeluddin/test-repo.git
This creates a pointer.
Key of pointer is
Value of pointer is
One of the benefits the key origin provides, is that, you do not have to memorize the whole URL, you can just use the short name.
You can name anything other than origin but this is a conventional and/or standard way so just go with the flow because if you move away from conventions/standards, it'll be difficult for others to maintain/upgrade/fix your projects.
Similarly, you can add as many pointers as you want. You can download project/changes from one (remote location) pointer and push it to another pointer (remote location)
You can find out about remotes with
git remove -v command:
git push -u origin mainThis command pushes (uploads) changes to origin which are present in main branch.
Pushing Changes First Time
If you are pushing changes first time then you will be required to log in. Do not worry about this step, because, you need to authenticate that you have the rights to push changes to the selected repository.
This is what you see in your CLI after you have successfully authenticated yourself and pushed the changes.
Refresh the page on GitHub.
This is what you see on your GitHub repo page:
That's it folks!
Lets meet again and discuss most important remote git commands for daily usage.