Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use the git init command

Shulou Source: shulou.com Published: 2022-06-01 01:50:40 10月17日 Update

This article mainly explains "how to use the git init command". Friends who are interested might as well take a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn how to use the git init command.

Git init

Git uses the git init command to initialize a Git repository, and many of the Git commands need to be run in the Git repository, so git init is the first command to use Git.

After executing the git init command, the Git repository generates a .git directory that contains all the metadata for the resource, while the other project directories remain unchanged.

Usage

Using the current directory as the Git repository, we just need to initialize it.

Git init

After the command is executed, a .git directory is generated in the current directory.

Use the directory we specified as the Git repository.

Git init newrepo

After initialization, a directory called .git appears under the newrepo directory, where all the data and resources needed by Git are stored.

If there are several files in the current directory that want to be versioned, you need to tell Git to start tracking these files with the git add command, and then submit:

$git add * .c$ git add README$ git commit-m 'initialize the project version'

The above command submits the directory ending with .c and the README file to the repository.

Note: in Linux systems, commit messages use single quotation marks, Windows systems use double quotes, and commit messages use double quotation marks.

So it's OK to git commit-m 'submit description' in git bash, and use double quotation marks git commit-m 'submit description' in the Windows command line.

At this point, I believe you have a deeper understanding of "how to use the git init command". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Directories commands warehouses quotation marks files information content data methods versions systems resources projects learning generation practical deeper lower methods of use interests Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Docker OPPO Reno Shulou Technology Xiaomi