Git 使用40个16进制字符的SHA-1 Hash来唯一标识对象
4a21da353d21312d1231f1212e123124
Git有4种对象
1 blob
2 tree
3 commit
4 tag
得到Git仓库的两种途径
1、git init 【file name】
2、git clone 【已有的仓库名称或者远程的地址】【[clone到本地的名称】
=======================================================================================================
songyanchengdeMacBook-Pro:~ Jax$ git init Jax_git
Initialized empty Git repository in /Users/Jax/Jax_git/.git/
songyanchengdeMacBook-Pro:~ Jax$ cd Jax_git/
songyanchengdeMacBook-Pro:Jax_git Jax$ touch a
songyanchengdeMacBook-Pro:Jax_git Jax$ touch b
songyanchengdeMacBook-Pro:Jax_git Jax$ git add a b
songyanchengdeMacBook-Pro:Jax_git Jax$ git status
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: a
new file: b
songyanchengdeMacBook-Pro:Jax_git Jax$ git commit -m "init commit"
[master (root-commit) fb81826] init commit
Committer: Jax <Jax@songyanchengdeMacBook-Pro.local>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly. Run the
following command and follow the instructions in your editor to edit
your configuration file:
git config --global --edit
After doing this, you may fix the identity used for this commit with:
git commit --amend --reset-author
2 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 a
create mode 100644 b
songyanchengdeMacBook-Pro:Jax_git Jax$ vim a
songyanchengdeMacBook-Pro:Jax_git Jax$ 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")
songyanchengdeMacBook-Pro:Jax_git Jax$ git add a
songyanchengdeMacBook-Pro:Jax_git Jax$ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: a
songyanchengdeMacBook-Pro:Jax_git Jax$ git commit -m "modify a"
[master 31a1b55] modify a
Committer: Jax <Jax@songyanchengdeMacBook-Pro.local>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly. Run the
following command and follow the instructions in your editor to edit
your configuration file:
git config --global --edit
After doing this, you may fix the identity used for this commit with:
git commit --amend --reset-author
1 file changed, 1 insertion(+)
songyanchengdeMacBook-Pro:Jax_git Jax$ git rm a
rm 'a'
songyanchengdeMacBook-Pro:Jax_git Jax$ ls
b
songyanchengdeMacBook-Pro:Jax_git Jax$ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: a
songyanchengdeMacBook-Pro:Jax_git Jax$ git reset HEAD a
Unstaged changes after reset:
D a
songyanchengdeMacBook-Pro:Jax_git Jax$ ls
b
songyanchengdeMacBook-Pro:Jax_git Jax$ git checkout a
songyanchengdeMacBook-Pro:Jax_git Jax$ ls
a b
songyanchengdeMacBook-Pro:Jax_git Jax$ git rm --cached a
rm 'a'
songyanchengdeMacBook-Pro:Jax_git Jax$ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: a
Untracked files:
(use "git add <file>..." to include in what will be committed)
a
songyanchengdeMacBook-Pro:Jax_git Jax$ git add a
songyanchengdeMacBook-Pro:Jax_git Jax$ git mv a c
songyanchengdeMacBook-Pro:Jax_git Jax$ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
renamed: a -> c
如果不想添加XXX文件,创建.git_ignore
git add .gitignore