Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

hasabTech profile imageShameel Uddin
Shameel Uddin forhasabTech

Posted on • Originally published atarticle.hasabtech.com

     

GitHub - Creating First Repo

So, we have learned Basics of:

Time to move on and create our first repository on GitHub.

Creating First Repository on GitHub

Navigate toRepositories and click onNew

Image description

Fill out basic info:

Image description

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 onCreate Repository:

Image description

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.

Image description

Most of the commands have already been studied in our article where we got out basics of Git straight.

Lets rewind them a bit..

  1. echo "# test-repo" >> README.md
    ThiscreatesREADME.md file in the folder/directory you are present in andsave"# test-repo" as its contents in the file.

  2. git init
    Thisinitializes the git repository in folder/directory you are present int.

  3. git add README.md
    README.md file which was created as a result of first command is now added toStaging Area

  4. git commit -m "first commit"

Thiscommits the changes with the messagefirst commit.

  1. git branch -M mainThiscreates a branch called asmain.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.

  1. git remote add origin https://github.com/shameeluddin/test-repo.git

This creates a pointer.
Key of pointer isorigin
Value of pointer ishttps://github.com/shameeluddin/test-repo.git

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 thanorigin 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 withgit remove -v command:
Image description

  1. git push -u origin mainThis commandpushes (uploads) changes toorigin which are present inmain branch.

Pushing Changes First Time

If you are pushing changes first time then you will be required to log in.
Image description
Image description
Do not worry about this step, because, you need to authenticate that you have the rights to push changes to the selected repository.

Result

This is what you see in your CLI after you have successfully authenticated yourself and pushed the changes.

Image description

Refresh the page on GitHub.

This is what you see on your GitHub repo page:
Image description

That's it folks!

Lets meet again and discuss most important remote git commands for daily usage.

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

More fromhasabTech

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp