English 中文(简体)
摘除经修正的犯案
原标题:Remove file from amended commit

我把承诺推向一个回波,我意外地在其中添加了一个档案。 没有人会从遥远的传票中转过来,因此我可以篡改历史。 但是,当我从当地承诺中删除档案(帐篷、不从源头控制或软盘),我无法推动变化。 git 推力 最新信息

最佳回答

虽然我所做的事情与科林和恩德罗登提出的类似,

The answer was to use

git push +sa1:sa1

我的分支是Sa1。 这迫使甚至无所作为。

问题回答

阁下:

git checkout HEAD~ -- path/to/your/file
git add path/to/your/file
git commit --amend -C HEAD

git diff -p HEAD~ -- path/to/your/file | git apply -R
git commit --amend -C HEAD

git reset HEAD~ -- path/to/your/file
git commit --amend -C HEAD

Try:

git rm --cached <yourfile>
git commit --amend
git push -f

如果你需要重新作出全部承诺,就设法使用

git reset HEAD^
git add <files to be part of the commit>
# or git add -pu
git commit -C <previous commit number>

在这样做之前,您需要保留最后数目,以便能够重新使用承诺的信息/日期/作者。

With these two commands you immediately revert all changes to FILE in the last commit without changing its (working tree) contents:

git reset HEAD~ "FILE"
git commit --amend --no-edit

https://superuser.com/a/567550”

请注意,这还将增加目前对承诺进行的所有改动,因此,您不妨先操作<条码>(git re-parse --git-dir)


此前的解决办法来自@ColinHebert的答复

git diff -p HEAD~ -- "FILE" | git apply --reverse --cached
git commit --amend --no-edit




相关问题
Tracking Versions, Builds, Revisions, with TortiseSVN

I am the sole developer on a project and have been using tortoiseSVN for quite a while. Now Id like to start getting version information working correctly in the project I.E. show Major Version, Minor ...

Tips on upgrading CVS to git/hg?

We still use CVS, I use git and hg for my personal use though I m still a novice at both, but I realize they re much more modern and better, faster, distributed, etc. It s just everyone is so ...

How to handle different csproj [closed]

I am working in a team of five. We are working on a C# application with five csprojects. The problem is that for each csproject, each of my colleagues has their own ideas on how to reference a DLL; ...

Changing username in SVN+SSH URI on the fly in working copy

I am using SVN+SSH to check out a working copy of repository from an SVN server on which all developers are members of a developer group and have full read/write permissions on the repository ...

How to search for file in subversion server?

Is there a way to search for a file in a subversion repository? Something similar to Unix find command, with which I can find the location of a file in a repository. I know there is svn list, but ...

热门标签