git学习(六):git stash

时间:2023-03-09 20:33:27
git学习(六):git stash

对于更改操作的处理

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

 git status                     // 查看工作区的状态

 // 对于已经git add工作区中文件
git reset HEAD <file> ... // 已经添加但是还没有commit的更改,通过这命令可以取消add
git commit <file> // 将更改加入版本库中 // 对于还没有add的工作区中的文件
git checkout -- <file> // 将commit后的数据检出替换工作区中的更改
git add <file>

现在需要学习的是:

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

保存进度:git stash

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

 root@tuhooo:~/workspace/demo # git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage) new file: a/b/c/hello.txt
modified: welcome.txt 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/b/c/hello.txt root@tuhooo:~/workspace/demo # git stash
Saved working directory and index state WIP on master: ac31089 empyt commit?
root@tuhooo:~/workspace/demo # git status
On branch master
nothing to commit, working tree clean

神奇~