git stash (23)

查看一下git stash的用法:

$ git stash -h
usage: git stash list [<options>]
   or: git stash show [<stash>]
   or: git stash drop [-q|--quiet] [<stash>]
   or: git stash ( pop | apply ) [--index] [-q|--quiet] [<stash>]
   or: git stash branch <branchname> [<stash>]
   or: git stash save [--patch] [-k|--[no-]keep-index] [-q|--quiet]
                      [-u|--include-untracked] [-a|--all] [<message>]
   or: git stash [push [--patch] [-k|--[no-]keep-index] [-q|--quiet]
                       [-u|--include-untracked] [-a|--all] [-m <message>]
                       [-- <pathspec>...]]
   or: git stash clear

它主要是用来保存当前临时的开发环境,比如想拉一个新分支,但是由于当前部分代码改动了,就可以先保存当前的开发环境,拉完分支之后再恢复回来。

第一步保存开发环境信息:

$ git stash
Saved working directory and index state WIP on md12-bootloader-app: 4fcf21c9 +AHB-md12-bootloader-app-24 New feature support misc xPortGetFreeHeapSize dump free mem info

第二步:查看保存列表

$ git stash list
stash@{0}: WIP on md12-bootloader-app: 4fcf21c9 +AHB-md12-bootloader-app-24 New feature support misc xPortGetFreeHeapSize dump free mem info

第三步: 指定恢复特定索引

$ git stash apply 0
On branch md12-bootloader-app
Your branch is up to date with 'origin/md12-bootloader-app'.

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:   SDK_2.8.0_MIMXRT1170-EAR3/boards/easyarm-rt1170-revb/driver_examples/gpio_bootloader/led_output/cm7/bsp/flexspi/app.h
        modified:   SDK_2.8.0_MIMXRT1170-EAR3/boards/easyarm-rt1170-revb/driver_examples/gpio_bootloader/led_output/cm7/bsp/flexspi/flexspi_nor_flash_ops.c
        modified:   SDK_2.8.0_MIMXRT1170-EAR3/boards/easyarm-rt1170-revb/driver_examples/gpio_bootloader/led_output/cm7/gpio_led_output.c
        modified:   SDK_2.8.0_MIMXRT1170-EAR3/boards/easyarm-rt1170-revb/driver_examples/gpio_bootloader/led_output/cm7/mdk/JLinkLog.txt
        modified:   SDK_2.8.0_MIMXRT1170-EAR3/boards/easyarm-rt1170-revb/driver_examples/gpio_bootloader/led_output/cm7/mdk/igpio_led_output_cm7.uvoptx
        modified:   SDK_2.8.0_MIMXRT1170-EAR3/boards/easyarm-rt1170-revb/driver_examples/pwm/cm7/mdk/pwm_cm7.uvoptx
        modified:   SDK_2.8.0_MIMXRT1170-EAR3/boards/easyarm-rt1170-revb/driver_examples/pwm/cm7/mdk/pwm_cm7.uvprojx
        modified:   boards/easyarm-rt1170/awtk_examples/awtk_vglite_demo/cm7/mdk/JLinkLog.txt
        modified:   boards/easyarm-rt1170/awtk_examples/awtk_vglite_demo/cm7/mdk/awtk_demo.uvoptx

 

如果转载的话,请保留本博客的原始出处信息:https://www.cnblogs.com/lianghong881018/

 

posted @ 2022-05-30 11:07  嵌入式实操  阅读(38)  评论(0编辑  收藏  举报