原文:<wbr style="line-height:25px"><a rel="nofollow" href="http://gitbook.liuhui998.com/4_5.html" style="color:rgb(245,149,19); line-height:25px; text-decoration:none">http://gitbook.liuhui998.com/4_5.html</a>
<div style="line-height:25px">
<div style="line-height:25px"><span style="line-height:25px">一、基本操作</span></div>
<div style="line-height:25px"><span style="color:#000080; line-height:25px">当你正在做一项复杂的工作时, 发现了一个和当前工作不相关但是又很讨厌的bug. 你这时想先修复bug再做手头的工作, 那么就可以用 git stash 来保存当前的工作状态, 等你修复完bug后,执行'反储藏'(unstash)操作就可以回到之前的工作里.</span></div>
<div style="line-height:25px">
<span style="color:#0000ff; line-height:25px">$</span><span style="color:#ff6600; line-height:25px">git</span><span style="color:#ff00ff; line-height:25px">stash</span><span style="color:#0000ff; line-height:25px"></span><span style="color:#ff6600; line-height:25px">save</span><span style="color:#0000ff; line-height:25px">"</span><span style="color:#808000; line-height:25px">work
in progress for foo feature</span><span style="color:#0000ff; line-height:25px">"</span>
</div>
<div style="line-height:25px"><span style="color:#000080; line-height:25px">上面这条命令会保存你的本地修改到储藏(stash)中, 然后将你的工作目录和索引里的内容全部重置, 回到你当前所在分支的上次提交时的状态.</span></div>
<div style="line-height:25px"><span style="line-height:25px; color:rgb(0,0,128)">好了, 你现在就可以开始你的修复工作了.</span></div>
<div style="line-height:25px"><span style="color:#3366ff; line-height:25px">... edit and test ...</span></div>
<div style="line-height:25px"><span style="color:#3366ff; line-height:25px">$ git commit -a -m "blorpl: typofix"</span></div>
<div style="line-height:25px"><span style="color:#000080; line-height:25px">当你修复完bug后, 你可以用git stash apply来回复到以前的工作状态.</span></div>
<div style="line-height:25px">
<span style="color:#0000ff; line-height:25px">$</span><span style="color:#ff6600; line-height:25px">git</span><span style="color:#0000ff; line-height:25px"></span><span style="color:#ff00ff; line-height:25px">stash</span><span style="color:#0000ff; line-height:25px"></span><span style="color:#ff9900; line-height:25px">apply</span>
</div>
<div style="line-height:25px"><span style="line-height:25px">二、储藏队列</span></div>
<div style="line-height:25px">
<span style="line-height:25px; color:rgb(0,0,128)">你也可多次使用'</span><span style="color:#993300; line-height:25px">git stash</span><span style="color:#000080; line-height:25px">'</span><span style="line-height:25px; color:rgb(0,0,128)">命令, 每执行一次就会把针对当前修改的‘储藏’(stash)添加到储藏队列中.</span>
</div>
<div style="line-height:25px">
<span style="line-height:25px; color:rgb(0,0,128)">用'</span><span style="color:#ff6600; line-height:25px">git</span><span style="color:#ff00ff; line-height:25px">stash</span><span style="color:#ff9900; line-height:25px">list'</span><span style="line-height:25px; color:rgb(0,0,128)">命令可以查看你保存的'储藏'(stashes):</span>
</div>
<div style="line-height:25px">
<span style="color:#0000ff; line-height:25px">$></span><span style="color:#ff6600; line-height:25px">git</span><span style="color:#ff00ff; line-height:25px">stash</span><span style="color:#ff6600; line-height:25px"></span><span style="color:#ff9900; line-height:25px">list</span>
</div>
<div style="line-height:25px"><span style="color:#3366ff; line-height:25px">stash@{0}: WIP on book: 51bea1d... fixed images</span></div>
<div style="line-height:25px"><span style="color:#3366ff; line-height:25px">stash@{1}: WIP on master: 9705ae6... changed the browse code to the official repo</span></div>
<div style="line-height:25px">
<span style="color:#000080; line-height:25px">可以用类似'</span><span style="color:#ff6600; line-height:25px">git</span><span style="color:#ff00ff; line-height:25px">stash</span><span style="color:#ff6600; line-height:25px"></span><span style="color:#ff9900; line-height:25px">apply</span><span style="color:#808000; line-height:25px">stash@{1}</span><span style="color:#000080; line-height:25px">'的命令来使用在队列中的任意一个'储藏'(stashes).</span>
</div>
<div style="line-height:25px">
<span style="color:#000080; line-height:25px">'</span><span style="color:#ff00ff; line-height:25px">git stash clear</span><span style="color:#000080; line-height:25px">‘则</span>是用来清空这个队列.</div>
</div>
</wbr>
分享到:
相关推荐
增强版的 git stash,可以给每个 stash 命名,可以通过指定的名字恢复 stash,也可以获取当前名字和 stash 的映射关系列表
就像git stash命令一样,但是对于Subversion。 如果您不懂git,则应该阅读 Svn-stash允许您隐藏不想立即提交的更改。 在某些情况下,这可能会更有用。 为什么? 我喜欢git,我认为它应该用在任何程序员开始的新...
gitstash.stash 使用自定义选项生成存储。 stash only使用stash only来生成简单的隐藏。 使用“ Keep index可以存储,但要保留添加到索引中的所有更改(保留它们)。 如果要隐藏未跟踪的文件,请使用“ Include ...
git stash 用于暂存工作区未提交的内容,便于在同时开发多个分支需要切换时保存当前分支进度。 list 语法 git stash list [] ,与git log功能类似,列出储藏列表,options 参数可以参考git log的参数 show 语法 git ...
前端大厂最新面试题-git stash.docx
一、简介1)执行git stash命令,发现只会把已跟踪的文件暂存起来:2)然后执行git stash pop,发现之前的暂存区的状态会丢失:三、总结由于之前没
主要介绍了git stash暂存的操作方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
哎呀 用法 $ npm install -g @mattbun/oops $ oops COMMAND running command... $ oops (-v | --version | version) @mattbun/oops/0.0.3 linux-x64 node-v12.19.0 $ oops --help [COMMAND] USAGE ...
注意你的 git 藏匿处! 这个小脚本提醒你,你已经为当前分支打开了 git stashes。 永远不要忘记你的藏品! 哇? 假设您必须存储一些代码来... git clone git@github.com:depressiveRobot/stash-aware.git ~/.oh-my-zs
git视频教程.4.7.Git 命令 - git log、git stash、git tag.mp4 git视频教程.5.1.Git 命令 - git fetch.mp4 git视频教程.5.2.Git 命令 - git pull.mp4 git视频教程.5.3.Git 命令 - git push.mp4 git视频教程.5.4.Git ...
git stash && git checkout branch-a && git stash pop stash@{1} 如果您觉得这个工作流程听起来很熟悉,那就是git-stashout发光的地方! 正在安装 带 scarf install git-stashout 手动地 将git-stashout放在PATH...
> list capabilities./run --setup -> install some known modules./run --update -> update bvs and modules/..../run --clean -> cleanup of ALL (c)make generated build files注意:-- --update运行git stash;...
9.3 探秘 git stash/ 109 第10章 Git 基本操作/ 114 10.1 先来合个影/ 114 10.2 删除文件/ 114 10.2.1 本地删除不是真的删除/ 115 10.2.2 执行 git rm 命令删除文件/ 116 10.2.3 命令git add -u快速标记删除/ 117 ...
Git_版本管理_#10_临时修复_(stash)_(教学_教程_tutorial)
Take control with Git's advanced features: reflog, rebase, stash, and more. Use Git with cloud-based Git repository host services like Github and Bitbucket. See how Git's used effectively on large ...
众所周知,版本系统在开发环境中是必不可少的,但是我们可以把代码免费的托管到GitHub上,如果我们不原意公开项目的源代码,公司又不想付费使用,那么我们可以自己搭建一台Git服务器,可以用Gitosis来管理公钥,还是...
-hard origin/main藏git stash listgit stash showgit restore -s stash@{0} -- ${FILENAME}目录结构├─── ... # s/w│├───contents│ ├───images # image files│ └───svg # svg fi
Git-2.21.0-64 for windows Git 2.23 Release Notes ====================== Updates since v2.22 ------------------- Backward compatibility note * The "--base" option of "format-patch" computed the ...
Finally, you will discover how you can work offline with Git, how to track what is going on behind the scenes, and how to use the stash for different purposes. What you will learn Understand the ...