【问题标题】:Doing a git stash doesn't remove changes in git local [duplicate]执行 git stash 不会删除 git local [重复]
【发布时间】:2015-07-10 06:46:33
【问题描述】:

当我执行git status 时,我看到一些文件发生了本地更改(似乎是缩进更改)。

当我执行git stash 时,它不会从队列中删除这些文件。它阻止我的自动拉脚本从远程 git 获取。

$ git stash
Saved working directory and index state WIP on develop: 05c60a5 Merge remote-tracking branch 'origin/develop' into develop
HEAD is now at 05c60a5 Merge remote-tracking branch 'origin/develop' into develop

$ git stash
On branch develop 
Your branch and 'origin/develop' have diverged and have 23 and 127 different commit(s) each, respectively.

Changed but not updated:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory) 

    modified:   config/buznames/businessname_map.
    modified:   public/css/_lib/dropdown.less
    modified:   public/css/_lib/secureBadge.less

【问题讨论】:

标签: git git-stash


【解决方案1】:

git stash 将删除所有未提交更改,但不会删除您的本地(未推送)提交。

我相信您的本地分支已经分道扬镳,并且您在尝试拉取时遇到了合并冲突。您必须先解决这些冲突,然后才能继续拉取请求。

如果您尝试删除开发分支中相对于远程分支的所有本地提交,您可以执行以下操作:

$ git checkout develop
$ git fetch origin develop
# Reset develop branch back to origin/develop
$ git reset --hard origin/develop

注意:这将删除/丢弃您所有的本地提交。您将无法恢复它们

【讨论】:

  • git reset --hard origin/develop 为我工作。谢谢
猜你喜欢
  • 1970-01-01
  • 2018-02-02
  • 1970-01-01
  • 1970-01-01
  • 2012-12-25
  • 2012-09-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多