git对象
创建裸仓库和非裸仓库
单凯@shankai MINGW32 /e/gitRepository
$ git init git_non_bare_1
Initialized empty Git repository in E:/gitRepository/git_non_bare_1/.git/
单凯@shankai MINGW32 /e/gitRepository
$ cd git_non_bare_1/.git/
单凯@shankai MINGW32 /e/gitRepository/git_non_bare_1/.git (GIT_DIR!)
$ ls
config description HEAD hooks/ info/ objects/ refs/
单凯@shankai MINGW32 /e/gitRepository/git_non_bare_1/.git (GIT_DIR!)
$ cd ../..
单凯@shankai MINGW32 /e/gitRepository
$ pwd
/e/gitRepository
单凯@shankai MINGW32 /e/gitRepository
$ git init --bare git_bare_1
Initialized empty Git repository in E:/gitRepository/git_bare_1/
单凯@shankai MINGW32 /e/gitRepository
$ cd git_bare_1/
config HEAD info/ refs/
description hooks/ objects/
单凯@shankai MINGW32 /e/gitRepository
$ cd git_bare_1/
单凯@shankai MINGW32 /e/gitRepository/git_bare_1 (BARE:master)
$ ls
config description HEAD hooks/ info/ objects/ refs/
单凯@shankai MINGW32 /e/gitRepository/git_bare_1 (BARE:master)
$
在当前文件夹下创建仓库
单凯@shankai MINGW32 /e/gitRepository
$ mkdir git_init_1
单凯@shankai MINGW32 /e/gitRepository
$ cd git_init_1/
单凯@shankai MINGW32 /e/gitRepository/git_init_1
$ git init
Initialized empty Git repository in E:/gitRepository/git_init_1/.git/
单凯@shankai MINGW32 /e/gitRepository/git_init_1 (master)
$
复制一个仓库
单凯@shankai MINGW32 /e/gitRepository/git_init_1 (master)
$ pwd
/e/gitRepository/git_init_1
单凯@shankai MINGW32 /e/gitRepository/git_init_1 (master)
$ cd ..
单凯@shankai MINGW32 /e/gitRepository
$ git clone git_bare_1/ git_clone_1
Cloning into 'git_clone_1'...
warning: You appear to have cloned an empty repository.
done.
单凯@shankai MINGW32 /e/gitRepository
$ cd git_clone_1/.git/
单凯@shankai MINGW32 /e/gitRepository/git_clone_1/.git (GIT_DIR!)
$ ls
config description HEAD hooks/ info/ objects/ refs/
单凯@shankai MINGW32 /e/gitRepository/git_clone_1/.git (GIT_DIR!)
$ ^C
单凯@shankai MINGW32 /e/gitRepository/git_clone_1/.git (GIT_DIR!)
$
//提交文件
单凯@shankai MINGW32 /e/gitRepository
$ cd git_init_1/
单凯@shankai MINGW32 /e/gitRepository/git_init_1 (master)
$ ls
单凯@shankai MINGW32 /e/gitRepository/git_init_1 (master)
$ clear
单凯@shankai MINGW32 /e/gitRepository/git_init_1 (master)
$ touch a
单凯@shankai MINGW32 /e/gitRepository/git_init_1 (master)
$ touch b
单凯@shankai MINGW32 /e/gitRepository/git_init_1 (master)
$ git add a b
单凯@shankai MINGW32 /e/gitRepository/git_init_1 (master)
$ git status
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: a
new file: b
单凯@shankai MINGW32 /e/gitRepository/git_init_1 (master)
$ git commit
a b
单凯@shankai MINGW32 /e/gitRepository/git_init_1 (master)
$ git commit -m "Initial commit"
[master (root-commit) b590d29] Initial commit
2 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 a
create mode 100644 b
单凯@shankai MINGW32 /e/gitRepository/git_init_1 (master)
$ vi a
单凯@shankai MINGW32 /e/gitRepository/git_init_1 (master)
$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: a
no changes added to commit (use "git add" and/or "git commit -a")
单凯@shankai MINGW32 /e/gitRepository/git_init_1 (master)
$ git add a
warning: LF will be replaced by CRLF in a.
The file will have its original line endings in your working directory.
单凯@shankai MINGW32 /e/gitRepository/git_init_1 (master)
$ git status
warning: LF will be replaced by CRLF in a.
The file will have its original line endings in your working directory.
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: a
单凯@shankai MINGW32 /e/gitRepository/git_init_1 (master)
$ git commit -m "modified a"
[master warning: LF will be replaced by CRLF in a.
The file will have its original line endings in your working directory.
7e767db] modified a
warning: LF will be replaced by CRLF in a.
The file will have its original line endings in your working directory.
1 file changed, 7 insertions(+)
单凯@shankai MINGW32 /e/gitRepository/git_init_1 (master)
$ git status
On branch master
nothing to commit, working directory clean
单凯@shankai MINGW32 /e/gitRepository/git_init_1 (master)
$