zoukankan      html  css  js  c++  java
  • git stash部分文件

    情景描述:
    修改大量文件需要提交,其中一个或多个文件为只针对于本地的环境配置文件,例如proxy.js/ts文件,在不提交这些本地配置文件的情况下提交剩余其他文件。
    1.查看当前状态,确定不需要提交的文件

    git status

    2.逐个文件判断是否需要stash,需要的y 不需要的n

    git stash -p //它是一个交互式命令,我们可以一个文件一个文件的遍历,决定每个文件的操作方式.

    root /u/c/s/cbs (master)# 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
    
    遇到我们需要stash的文件,我们就y,不需要stash需要commit的文件,我们就n,如果接下来没有需要stash的文件,则直接q退出就行.
    恢复stash

    git stash pop //恢复最近一次

  • 相关阅读:
    kali环境下如何安装最新版cobalt strike
    win10结束进程时拒绝访问的处理办法
    Windows下Postgresql数据库的下载与配置方法
    ubuntu下安装及配置git的方法
    运行和控制Nginx
    nginx安装(详解)
    ubuntu安装nginx
    在Windows安装运行Kafka
    linux下安装使用虚拟环境
    《操作系统真象还原》线程
  • 原文地址:https://www.cnblogs.com/xuchao-blogs/p/14817714.html
Copyright © 2011-2022 走看看