【问题标题】:git file still in modified state after reset and checkout from master to feature branch重置并从主分支签出到功能分支后,git 文件仍处于修改状态
【发布时间】:2020-07-09 17:06:44
【问题描述】:

我想在我的功能分支中重置 1 个文件,我按照这里的建议做了:
Git reset single file in feature branch to be the same as in master

但是当我执行 git status 时,我仍然看到文件在我的功能分支中被修改 当我提出拉取请求时,我仍然在这个文件中看到合并。 尝试做:

git reset HEAD include/tools.h

然后

git push 

但仍处于修改状态

$ git 状态

On branch feature/myfix
Your branch is up to date with 'origin/feature/myfix'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   include/tools.h

我应该如何重置这个文件,我想要主版本

【问题讨论】:

  • 如果您想放弃自己的工作,请尝试按照 Git 打印的说明操作:git checkout -- include/tools.h

标签: git


【解决方案1】:

要重置最后一次提交,

git reset HEAD~1

重置(删除当前更改)文件,

git checkout <file_name>

要重置暂存文件,

git reset <file_name>

【讨论】:

    猜你喜欢
    • 2019-04-18
    • 1970-01-01
    • 1970-01-01
    • 2023-02-04
    • 2013-02-21
    • 2013-06-02
    • 1970-01-01
    • 2011-01-18
    • 2023-04-01
    相关资源
    最近更新 更多