January 09, 2025

How to Create a New Git Repository on GitHub

If you have never used Git, you may not even have heard of it. Mo panic, just follow this introductory tutorial step by step, and you will soon have a brand new Git repository on GitHub.

Before we get started, let's start with a common misunderstanding: Git is not GitHub. Git is a version control system (or software) that helps you keep track of computer program and file changes at any time. It also allows you to collaborate with colleagues on programs, code, and file operations. GitHub and similar services (including GitLab and BitBucket) belong to websites that deploy Git programs and can host your code.

Step 1: Apply for a GitHub Account

Creating an account on the GitHub.com website (free) is the easiest way.

How to Create a New Git Repository on GitHub

Select a username (for example, octocat123), enter your email address and password, and then click Sign up for GitHub. After entering, you will see the interface of the illustration below:

How to Create a New Git Repository on GitHub

Step 2: Create a new warehouse

A repository is similar to a place or container where items can be stored; here, we create warehouse storage code. Select New Repository in the drop-down menu of the + symbol (in the upper right corner of the illustration, I have selected it).

How to Create a New Git Repository on GitHub

Name your repository (for example, Demo) and click Create Repository. No need to consider other options on this page.

Congratulations! You have already set up your first repository on GitHub.com.

Step 3: Create a file

When the warehouse is created, the interface will be consistent with the following:

How to Create a New Git Repository on GitHub

Don't panic, it's easier than it looks. Follow the steps. Ignore other content, pay attention to "...or create a new repository on the command line," on the screenshot.

Open the terminal in your computer.

How to Create a New Git Repository on GitHub

Type git and press Enter. If the command line shows bash: git: command not found, install the Git command on your operating system or distribution. Type git and press Enter to check if the installation was successful; if the installation is successful, you will see a lot of instructions for using the command.

Enter in the terminal:

Mkdir Demo

This command will create a directory (folder) called Demo.

The following command will switch the terminal directory and jump to the Demo directory:

Cd Demo

Then enter:

Echo"#Demo" >> README.md

Create a file named README.md and write #Demo. Check if the file was created successfully, please enter:

Cat README.md

This will show you the contents of the README.md file. If the file is created successfully, your terminal will show the following:

How to Create a New Git Repository on GitHub

Use a Git program to tell your computer that Demo is a directory managed by Git. Please enter:

Git init

Then, tell the Git program which files you care about and want to track any changes to it at the moment, enter:

Git add README.md

Step 4: Create a Submission

So far, you have created a file and have notified Git that it is now time to create a commit commit. Submissions can be seen as a milestone. Whenever you complete some work, you can create a commit and save the current version of the file so that you can return to the previous version and view the contents of the file at that time. Whenever you modify a file, you can create a different, new version of the file.

Create a submission, please enter:

Git commit -m"first commit"

That's it! You have just created a Git commit with a note of "first commit." Each time you submit, you must edit the comment information; it not only helps you identify the submission, but it also allows you to understand what changes you made to the file at the moment. So tomorrow, if you add new code to the file, you can write a commit message: "Add new code", and then when you come back one month later to view the submission record or Git log (ie the submission list), you also Can you know what you did in the folder at the time?

Step 5: Connect Your Computer to the GitHub Repository

Now it's time to connect your computer to the GitHub repository with the following command:

Git remote add origin https://github.com/ /Demo.git

Let us analyze this command step by step. We inform Git to add a new name called origin, which has the address https://github.com/ Remote (remote repository) for /Demo.git (it is also the GitHub address for your repository). When you submit code, this allows you to use the name origin instead of the full Git address when interacting with the Git repository at GitHub.com. Why is it called origin? Of course, you can call it something else, as long as you like it (usually).

We have now connected our local Demo repository copy to its remote copy on GitHub.com. Your terminal looks like this:

How to Create a New Git Repository on GitHub

At this point we have connected to the remote repository and can push our code to GitHub.com (eg upload README.md file).

After the execution is completed, your terminal will display the following information:

How to Create a New Git Repository on GitHub

Then if you visit https://github.com/ /Demo, you will see the situation shown in the screenshot:

How to Create a New Git Repository on GitHub

That's it! You have created your first GitHub repository, connected to your computer, and pushed (or uploaded) a file from your computer to a remote repository on GitHub.com called Demo. Next time, I will write about Git replication (downloading files from GitHub to your computer), adding new files, modifying existing files, and pushing (uploading) files to GitHub.

3D Uv Printer Machine

.Using high-quality UV ink, the color is realistic, restore the color of the picture
.Using Epson 10th generation nozzles, multi-channel printing C, M, Y, K+ white color to achieve white color one-time molding, and can achieve complex effects such as any part, no wire drawing, no stripes, optical resolution up to 5760*1440dpi, and the printing effect is clearer
.Smart Micro Touch Computer,Equipped with 8-inch touch computer, touch sensitive and stable, easy to use
.The color reproduction is more realistic, with partial concave and convex hollow relief effect

Smart Uv Printer,3D Photo Printer,3D Emboss Back Skin Printer,3D Relief Back Film Printer

Shenzhen TUOLI Electronic Technology Co., Ltd. , https://www.hydrogelprotector.com