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. Manjaro美化 配置教程

    Manjaro Linux的美化 切换源 sudo vi /etc/pacman.conf 加入arch源 [archlinuxcn] SigLevel = Optional TrustedOnly ...

  2. ln 硬链接与软链接

    1. 命令功能 ln 可以看做是link的简写,功能是创建链接文件,链接文件包括硬链接(hard link)和软链接(符号链接,symbolic link) 2. 语法格式 ln  [option]  ...

  3. jpype测试报错,找不到类raise _RUNTIMEEXCEPTION.PYEXC("Class %s not found" % name)

    最近用jpype测试java代码 公司电脑跑着没有问题,家里电脑怎么也不行,python,jdk版本啥的都一样,但总是报找不到类名的错误 raise _RUNTIMEEXCEPTION.PYEXC(& ...

  4. Petrozavodsk Winter-2018. AtCoder Contest. Problem I. ADD, DIV, MAX 吉司机线段树

    题意:给你一个序列,需要支持以下操作:1:区间内的所有数加上某个值.2:区间内的所有数除以某个数(向下取整).3:询问某个区间内的最大值. 思路(从未见过的套路):维护区间最大值和区间最小值,执行2操 ...

  5. [SDOI2011]消防(贪心,图论,树的直径)

    [SDOI2011]消防 题目描述 某个国家有n个城市,这n个城市中任意两个都连通且有唯一一条路径,每条连通两个城市的道路的长度为zi(zi<=1000). 这个国家的人对火焰有超越宇宙的热情, ...

  6. C++使用静态类成员时出现的一个问题

    开发环境 Qt Creator 4.8.2 编译器 MinGw 32-bit 在类中定义了一个static data member class Triangular{ public: static b ...

  7. 2018-10-01-weekly

    Algorithm 77. 组合 What 给定两个整数 n 和 k,返回 1 ... n 中所有可能的 k 个数的组合. How 利用递归的思想,当凑够k个数时,就回退回去,remove掉一个数,在 ...

  8. Task3.特征选择

    参考:https://www.jianshu.com/p/f3b92124cd2b 互信息 衡量两个随机变量之间的相关性,两个随机变量相关信息的多少. 随机变量就是随机试验结果的量的表示,可以理解为按 ...

  9. The list of list is modified unexpected, python

    Be careful! The list of list is modified unexpected, python # code patch A: list = [1,2,3,4,5,6,7] p ...

  10. Selenium-ActionChainsApi介绍

    ActionChains 模拟鼠标悬浮到某一个位置,做一系列的连贯操作,使用Selenium提供的ActionChains模块 引入方式 from selenium.webdriver.common. ...