git 存储合并冲突

git stash merge conflict

所以我有 2 个分支 masterfeature-example。我对 master 进行了代码更改,我不想将其推送到存储库。我想提取 feature-example 的提交,所以我做了

git stash
git pull 

然后

git checkout feature-example

现在我对 feature-example 分支做了一些我不想推送的更改,我想结帐到 master分支。所以我正在尝试

git stash pop

这让我很矛盾。当我尝试做

git checkout master 

它说,

app/assets/javascripts/abc.js: needs merge error: you need to resolve your current index first

所以我不希望我对 feature-example 的更改被推送,我希望它是旧的提交并且我想检出到 master 支线。

PS:我不希望对回购进行任何提交,即使是合并。

问的很奇怪,但有什么帮助吗?

要放弃特定文件中的更改,您可以使用 git checkout -- <file>:

我认为这可以解决您的问题:

git checkout -- abc.js

或者您可以解决冲突,然后提交更改并重置 head。最后一次提交将被删除:

A-B-C
    ^
  feature-example

git reset --hard HEAD~1

A-B
  ^
  feature-example