Git中stash和stage的差别

git中stash和stage两个功能乍一看上去挺相似的。其实二者是两个完全不同的概念。

1、stash是git中的一个命令。git stash的作用是把工作区(必须是工作区中已经被git追踪到的文件)和索引中的内容暂时存到一个堆上。而且这个堆是和分支不相关的。切换分支后,依然可以看到并使用。

2、stage是git中的一个区域。如下图所示。

可能你也发现了,staging area不就是index么,的确是的。下面是从国外一个网站上找到一段话:

The staging area is a file, generally contained in your Git directory, that stores information about what will go into your next commit. Its technical name in Git parlance is the “index”, but the phrase “staging area” works just as well.

(from https://git-scm.com/book/en/v2/Getting-Started-Git-Basics

猜你喜欢

转载自blog.csdn.net/u010037020/article/details/81537809