git学习(六):git stash

对于更改操作的处理

使用git status命令可以看到当前工作区的状态:

1 git status                     // 查看工作区的状态
2 
3 // 对于已经git add工作区中文件
4 git reset HEAD <file> ...      // 已经添加但是还没有commit的更改,通过这命令可以取消add
5 git commit <file>              // 将更改加入版本库中
6 
7 // 对于还没有add的工作区中的文件
8 git checkout -- <file>         // 将commit后的数据检出替换工作区中的更改
9 git add <file>

  

现在需要学习的是:

  • git reset和git checkout这两个命令
  • master和HEAD的概念的理解
  • git对象存储的实现机制

保存进度:git stash

运行完git stash之后会发现工作区尚未提交的改动和暂存区的改动全都不见了。

 1 root@tuhooo:~/workspace/demo # git status
 2 On branch master
 3 Changes to be committed:
 4   (use "git reset HEAD <file>..." to unstage)
 5 
 6         new file:   a/b/c/hello.txt
 7         modified:   welcome.txt
 8 
 9 Changes not staged for commit:
10   (use "git add <file>..." to update what will be committed)
11   (use "git checkout -- <file>..." to discard changes in working directory)
12 
13         modified:   a/b/c/hello.txt
14 
15 root@tuhooo:~/workspace/demo # git stash
16 Saved working directory and index state WIP on master: ac31089 empyt commit?
17 root@tuhooo:~/workspace/demo # git status
18 On branch master
19 nothing to commit, working tree clean

神奇~

猜你喜欢

转载自www.cnblogs.com/tuhooo/p/9206452.html