Git Tutorial Create warehouse Details _ Tips

Source: Internet
Author: User
Tags svn git clone

Git Creates a warehouse

In this section we will show you how to create a Git repository.

You can use a directory that already exists as a git repository.

Git init

Git Initializes a git repository using the git init command, and many of Git's commands need to be run in Git's warehouse, so git init is the first command to use Git.

After the execution of the GIT init command is completed, the Git warehouse generates a. Git directory that contains all of the metadata for the resource, and the other project directories remain unchanged (unlike SVN will generate in each subdirectory. The SVN directory, git only generates a. git directory in the repository's root directory).

How to use

Using the current directory as a git repository, we just have to initialize it.

Git init

When the command is done, a. Git directory is generated in the current directory.

Use our specified directory as a git repository.

Git init newrepo

After initialization, a directory named. Git appears in the Newrepo directory, and all of the data and resources that git requires are stored in this directory.

If you have several files in the current directory that you want to include in version control, you need to first tell Git to start tracking the files with the git add command, and then submit:

$ git Add *.c
$ git Add README
$ git commit-m ' Initialize version of Project '

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

git clone

We use Git clone to copy items from the existing Git repository (like svn checkout).

The command format for the Clone warehouse is:

git clone <repo>

If we need to clone to a specified directory, you can use the following command format:

Git clones <repo> <directory>

Parameter description:

Repo:git Warehouse.
Directory: Local directory.

For example, to clone the Git code warehouse Grit for Ruby language, you can use the following command:

$ git clone git://github.com/schacon/grit.git

After the command is executed, a directory named Grit is created in the current directory, containing a. Git directory that holds all downloaded version records.
If you want to define the name of the project directory you want to create yourself, you can specify a new name at the end of the command above:

$ git clone git://github.com/schacon/grit.git Mygrit

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.