git stash 当本地代码不想提交覆盖,又忙于其他分支,可以先储存起来。

git stash命令的作用就是将目前还不想提交的但是已经修改的内容进行保存至堆栈中,后续可以在某个分支上恢复出堆栈中的内容。这也就是说,stash中的内容不仅仅可以恢复到原先开发的分支,也可以恢复到其他任意指定的分支上。git stash作用的范围包括工作区和暂存区中的内容,也就是说没有提交的内容都会保存至堆栈中。

git stash

存储当前工作目录

$ git stash
Saved working directory and index state WIP on Practice: 2f70846 Complete practice
view and network

git stash list

查看之前存储的所有版本列表

$ git stash list
stash@{0}: WIP on Practice: 2f70846 Complete practice view and network
stash@{1}: WIP on Practice: 2f70846 Complete practice view and network
stash@{2}: WIP on Practice: 2f70846 Complete practice view and network
stash@{3}: WIP on Practice: 2f70846 Complete practice view and network
stash@{4}: WIP on Practice: 812e77b Add collectionView and AnswerView
stash@{5}: WIP on Practice: 53bb0c1 add tableView of questions and refactor the code of scrollView

git stash pop [stash_id]

恢复具体某一次的版本,如果不指定stash_id,则默认h恢复最新的存储进度  

$ git stash pop stash@{}
Auto-merging WePeiYang/Shared/Network/SolaSessionManager.swift
CONFLICT (content): Merge conflict in WePeiYang/Shared/Network/SolaSessionManager.swift
Auto-merging WePeiYang/Practice/Practice/QuestionTableView/OptionsCell.swift
CONFLICT (content): Merge conflict in WePeiYang/Practice/Practice/QuestionTableView/OptionsCell.swift
Auto-merging WePeiYang/Practice/Practice/Exercise/Model/ExerciseNetwork.swift
Auto-merging WePeiYang.xcodeproj/project.pbxproj
CONFLICT (content): Merge conflict in WePeiYang.xcodeproj/project.pbxproj
恢复之后,有时打开工程文件,会发现里面所有文件都不翼而飞了?!
莫慌,莫慌
这是因为出现合并冲突的问题而导致工程文件打不开。
这时候右击工程文件,单击“显示包内容”,打开“project.pbxproj”文件,然后command + f 搜索 “stashed”。把冲突部分删掉就可以重新打开啦
 

git stash drop [stash_id]
删除一个存储的进度。如果不指定stash_id,则默认删除最新的存储进度。

 
git stash clear
清除所有的存储进度

原文链接:https://www.jianshu.com/p/a634af0eb343?from=singlemessage

 

git stash 后"本地代码不见了"的更多相关文章

  1. Git 分支管理-git stash 和git stash pop

    https://blog.csdn.net/u010697394/article/details/56484492 合并分支,冲突是难免的,在实际协作开发中我们遇到的情况错综复杂,今天就讲两个比较重要 ...

  2. Git Stash方法

    命令:git stash1.使用git stash 保存当前的工作现场, 那么就可以切换到其他分支进行工作,或者在当前分支上完成其他紧急的工作,比如修订一个bug测试提交. 2.如果一个使用了一个gi ...

  3. Lunix git stash clear 或者 git stash drop后恢复的方法

    首先输入 git fsck --lost-found 会看到 一条一条的记录 这里的"dangling commit ..."你可以理解为记录的是你stash的id(经测试,该id ...

  4. git stash简介

    原文:http://gitbook.liuhui998.com/4_5.html 一.基本操作 当你正在做一项复杂的工作时, 发现了一个和当前工作不相关但是又很讨厌的bug. 你这时想先修复bug再做 ...

  5. 第23月第24天 git命令 .git-credentials git rm --cached git stash clear

    在git push的时候,有时候我们会想办法撤销git commit的内容 1.找到之前提交的git commit的id git log 找到想要撤销的id 2.git reset –hard id ...

  6. git学习(六):git stash

    对于更改操作的处理 使用git status命令可以看到当前工作区的状态: git status // 查看工作区的状态 // 对于已经git add工作区中文件 git reset HEAD < ...

  7. git stash使用一则

    当在新的分支工作,修改的文件提交到暂存区,这时,切换到其他分之,可能报错,因为米有commit,如果切换到其他分支,暂存区的修改可能丢失,我们可以使用git stash save -a(暂存区) &q ...

  8. IDEA:Git stash 暂存分支修改的代码

    IDEA:Git stash 暂存分支修改的代码 场景:当我们正在master分支开发新功能的时候,突然接到一个任务发现线上出现了一个紧急的BUG需要修复,由于没有打新分支做这部分新需求,这时正做到半 ...

  9. Git Stash紧急处理问题,需要切分支

    在开发过程中,大家都遇到过bug,并且有些bug是需要紧急修复的. 当开发人员遇到这样的问题时,首先想到的是我新切一个分支,把它修复了,再合并到master上. 当时问题来了,你当前正在开发的分支上面 ...

随机推荐

  1. dialog写进dll调用

    #ifdef DLG_WINDOW_API #define DLG_WINDOW_EXPORT __declspec(dllexport) #else #define DLG_WINDOW_EXPOR ...

  2. Java性能调优工具(Linux)

    为了能准确获得程序的性能信息,需要使用各种辅助工具.以下主要介绍了Linux上关于Java的系统性能分析工具,掌握这些工具,对于性能瓶颈定位.系统故障排查都有帮助. 1.top命令 [root@loc ...

  3. pytorch 指定GPU训练

    # 1: torch.cuda.set_device(1) # 2: device = torch.device("cuda:1") # 3:(官方推荐)import os os. ...

  4. centos 6.5 安装 jdk 8

    首先,检查是否已安装jdk,如果有,要先删除 rpm -qa|grep java rpm -e --nodeps filename 然后,从oracle官方网站下载jdk安装包:jdk-8u121-l ...

  5. D0g3_Trash_Pwn_Writeup

    Trash Pwn 下载文件 1 首先使用checksec查看有什么保护 可以发现,有canary保护(Stack),堆栈不可执行(NX),地址随机化没有开启(PIE) 2 使用IDA打开看看 mai ...

  6. Test 3.27 T2 旅行

    Description FGD 想从成都去上海旅游.在旅途中他希望经过一些城市并在那里欣赏风景,品尝风味小吃或者做其他的有趣的事情.经过这些城市的顺序不是完全随意的,比如说 FGD 不希望在刚吃过一顿 ...

  7. Harbor在安装前的几个注意点

    由于Harbor有1.8后和前的配置不一样,决定先安装1.8,结果报错如下 [root@localhost harbor]# ./install.sh [Step 0]: checking insta ...

  8. 20180809-Java继承

    // A.java public class A{ private int i; protected int j; public void func(){ }} // B.javapublic cla ...

  9. 20180709-Java循环结构

    while(布尔表达式){ //循环内容} public class Test{ public static void main(String args[]){ int x = 10; while(x ...

  10. 简易的Web自动化链接测试(Xenu)

    1.理解链接需要测试的测试点: [1] 要测试的链接页面是否存在 [2] 确定存在链接页面,然后就考虑跳转后的页面是不是对应需求的页面[3] 保证Web系统上没有孤立的页面(没有链接指向该页面) 2. ...