3、Git基本的工作流程


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


 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值