美文网首页
Git Stash用法整理

Git Stash用法整理

作者: xujiawei | 来源:发表于2021-06-08 16:05 被阅读0次

暂存部分文件(方法一)

# git stash -p

它是一个交互式命令,我们可以一个文件一个文件的遍历,决定每个文件的操作方式:

# git stash -p
diff --git a/cmd/scripts/cbs.sh b/cmd/scripts/cbs.sh
old mode 100644
new mode 100755
Stash mode change [y,n,q,a,d,/,?]? 

[y,n,q,a,d,/,?]分别代表的含义如下:

   y - stage this hunk
   n - do not stage this hunk
   q - quit; do not stage this hunk nor any of the remaining ones
   a - stage this hunk and all later hunks in the file
   d - do not stage this hunk nor any of the later hunks in the file
   g - select a hunk to go to
   / - search for a hunk matching the given regex
   j - leave this hunk undecided, see next undecided hunk
   J - leave this hunk undecided, see next hunk
   k - leave this hunk undecided, see previous undecided hunk
   K - leave this hunk undecided, see previous hunk
   s - split the current hunk into smaller hunks
   e - manually edit the current hunk
   ? - print help

暂存部分文件(方法二)
部分更改文件想放到暂存区,部分想保留更改,可结合 git add 和 git stash 实现:

# git add file1 file2 #保留更改文件至工作区
# git stash save -k #暂存未add的更改文件
# git reset #恢复工作区文件

恢复部分文件


# git stash list
stash@{0}
stash@{1}
stash@{2}
# git stash show -p stash@{1}
# git checkout stash@{0} -- <filename>

相关文章

  • Git Stash用法整理

    暂存部分文件(方法一) 它是一个交互式命令,我们可以一个文件一个文件的遍历,决定每个文件的操作方式: [y,n,q...

  • [ Git ] 快速参考

    配置 常用的用户信息配置 常用的别名配置 git rm 的用法 git reset 的用法 git stash 的...

  • Git stash 技巧

    Git stash常用技巧 git stash save git stash list git stash app...

  • stash 操作暂存区

    涉及命令:git stash、stash list、git stash apply、git stash drop ...

  • Git Stash用法

    Git Stash用法 最近在使用Git管理项目工程的时候,遇到了很多问题,也学习到了很多关于Git常见使用的技巧...

  • git stash用法

    每天都重复着一样的步骤,今天也是一样,打开电脑,先看git上面有没有代码更新,于是先pull代码,pull完了之后...

  • git stash用法

    git stash list 看有哪些git stash show stash@{0} 看某一个stash有哪些文...

  • git stash用法

    一、应用场景 1、 当正在dev分支上开发某个项目,这时项目中出现一个bug,需要紧急修复,但是正在开发的内容只是...

  • git stash 用法

    一、常用git stash命令: 1、git stash 能够将所有未提交的修改(工作区和暂存区)保存至堆栈中,用...

  • 【Git】stash

    stash git stash // 加入缓存区git stash save "注释"git stash list...

网友评论

      本文标题:Git Stash用法整理

      本文链接:https://www.haomeiwen.com/subject/mhkjeltx.html