命令格式
git init [-q | --quiet] [--bare] [--template=<template_directory>]
[--separate-git-dir <git dir>]
[--shared[=<permissions>]] [directory]
命令参数
--quiet, -q
安静模式,只打印错误和警告信息。
实例
a) 创建版本库
[huey@huey-K42JE git]$ mkdir hello_git [huey@huey-K42JE git]$ cd hello_git/ [huey@huey-K42JE hello_git]$ git init Initialized empty Git repository in /home/ucm/git/hello_git/.git/
b) 为已存在的代码库创建版本库
[huey@huey-K42JE git]$ mkdir hello_world [huey@huey-K42JE git]$ echo -e '#!/usr/bin/python print "hello world"' > hello_world/hello.py [huey@huey-K42JE git]$ chmod a+x hello_world/hello.py [huey@huey-K42JE git]$ cd hello_world/ [huey@huey-K42JE hello_world]$ git init Initialized empty Git repository in /home/huye/git/hello_world/.git/ [huey@huey-K42JE hello_world]$ git add . [huey@huey-K42JE hello_world]$ git commit -m "Start a new Git repository for an existing code base" [master (root-commit) b65bd46] Start a new Git repository for an existing code base 1 files changed, 2 insertions(+), 0 deletions(-) create mode 100755 hello.py