首页 > 其他分享 >git暂存本地修改

git暂存本地修改

时间:2022-10-06 09:22:05浏览次数:41  
标签:pull git stash 修改 本地 暂存

git暂存本地代码
在当前分支开发过程中,突然有紧急BUG需要切换分支修改,但你本地已经存在代码,需要push之后,才能切换分支
这个时候就可以使用git stash,进行暂存

  

在使用git pull代码时,经常会碰到有冲突的情况,提示如下信息:

Your branch is behind 'origin/master' by 123 commits, and can be fast-forwarded.

(use "git pull" to update your local branch)

Please, commit your changes or stash them before you can merge.

这个意思是说更新下来的内容和本地修改的内容有冲突,先提交你的改变或者先将本地修改暂时存储起来。

一.处理的方式非常简单,主要是使用git stash命令进行处理,分成以下几个步骤进行处理。---- 通常用这种方法

1、先将本地修改存储起来

$ git stash
e28cb8870961418204e82894a1e0fe6e.png

这样本地的所有修改就都被暂时存储起来 。是用git stash list可以看到保存的信息:

it stash暂存修改

其中stash@{0}就是刚才保存的标记。

2、pull内容

暂存了本地修改之后,就可以pull了。

$ git pull

3、还原暂存的内容

$ git stash pop stash@{0}

系统提示如下类似的信息:

Auto-merging c/environ.cCONFLICT (content): Merge conflict in c/environ.c

意思就是系统自动合并修改的内容,但是其中有冲突,需要解决其中的冲突。

标签:pull,git,stash,修改,本地,暂存
From: https://www.cnblogs.com/fdxjava/p/16757020.html

相关文章