Git creates repository commands and usage, git Repository

Source: Internet
Author: User
Tags git commands

Git creates repository commands and usage, git Repository

Git init

Git uses the git init command to initialize a Git repository. Many Git commands need to be run in the Git repository, So git init is the first command to use Git.

After the git init command is executed, the Git repository generates. git Directory, which contains all metadata of resources, and other project directories remain unchanged (unlike SVN, which will be generated in each subdirectory. svn directory. Git is generated only in the root directory of the repository. git directory ).

Usage

Use the current directory as the Git repository and we only need to initialize it.

git init

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

Use the specified directory as the Git repository.

git init newrepo

After initialization, a directory named. git will appear under the newrepo directory, where all the data and resources required by Git are stored.

If several files in the current directory want to be included in version control, you must first run the git add command to tell Git to start tracking these files and then submit them:

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

The preceding command submits the directory with a README file ending with. c to the repository.

Git clone

We use git clone to copy a project from an existing GIt repository (similar to svn checkout ).

The command format for cloning a repository is:

git clone 
 

To clone to a specified directory, use the following command format:

git clone 
  
  
 

Parameter description:

· Repo: Git repository;

· Directory: local directory;

After executing this command, a directory named grit is created under the current directory, which contains a. git directory to save all downloaded version records.

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.