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.