git stash

几年前的云笔记,整理至此。

git stash 可用来暂存当前正在进行的工作, 比如想pull 最新代码, 又不想加新commit, 或者另外一种情况,为了fix 一个紧急的bug,  先stash, 使返回到自己上一个commit, 改完bug之后再stash pop, 继续原来的工作。

首先用git status查看项目变更

F:\springboots\mis\til-mis>git status
On branch taskjob
Your branch is up-to-date with 'origin/jia01'.
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        modified:   pom.xml
        new file:   src/main/java/com/tilchina/mis/task/controller/TaskController.java
        new file:   src/main/java/com/tilchina/mis/task/domain/TaskCronJob.java
        new file:   src/main/java/com/tilchina/mis/task/factory/TaskSchedulerFactory.java
        new file:   src/main/java/com/tilchina/mis/task/job/TestJob.java
        new file:   src/main/java/com/tilchina/mis/task/mapper/TaskCronJobMapper.java
        new file:   src/main/java/com/tilchina/mis/task/service/TaskCronJobService.java
        new file:   src/main/java/com/tilchina/mis/task/service/TaskInitService.java
        new file:   src/main/java/com/tilchina/mis/task/service/impl/TaskCronJobServiceImpl.java
        new file:   src/main/java/com/tilchina/mis/task/util/TaskUtils.java
        modified:   src/main/resources/application-dev.yml
        new file:   src/main/resources/mapper/task/TaskCronJobMapper.xml

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        hs_err_pid13504.log

       使用git stash命令做代码变更的暂存:

         git stash ---- 将当前git status看到的修改进行暂存,操作完成后,再运行git status命令看不到文件修改,该操作没有备注,仅有版本号;

         git stash save "spring task" ---- 将当前修改保存,并且备注为"spring task";

F:\springboots\mis\til-mis>git stash save "spring task"
Saved working directory and index state On taskjob: spring task
HEAD is now at 1d75433 系统管理功能优化

F:\springboots\mis\til-mis>git status
On branch taskjob
Your branch is up-to-date with 'origin/jia01'.
Untracked files:
  (use "git add <file>..." to include in what will be committed)

        hs_err_pid13504.log

nothing added to commit but untracked files present (use "git add" to track)

         git stash list ---- 当你多次使用’git stash’命令后,你的栈里将充满了未提交的代码,这时候你会对将哪个版本应用回来有些困惑,“git stash list”命令可以将当前的Git栈信息打印出来,如图 

F:\springboots\mis\til-mis>git stash list
stash@{0}: On taskjob: spring task

释放暂存的修改,使用git stash pop,可参考:https://blog.csdn.net/yangfengjueqi/article/details/61665110

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值