0

作成したコミットのコミットメッセージを変更したかったので、次のことを試みました。

git commit --amend

(私が通常行うように)、しかし私はエラーを受け取りました:

Unable to find modified files; please check git status

これは奇妙なことです。コミットからファイルを追加/削除しようとはしていないので、メッセージを変更したいだけなので、ファイルを変更したかどうかは関係ありません。

誰かがこのエラーメッセージを説明できますか(そして理想的には、どうすればそれを乗り越えることができますか)?

* 編集 *

Mellowcandleが私のgitステータスをリクエストしました。ここにあります(多かれ少なかれ):

# On branch some_branch
# Your branch is ahead of 'origin/some_branch' by 1 commit.
#
# 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:   static/js/someFile.js
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   some/other/file
#   yet/another/file

*編集#2 *

git rebase -i(with )を実行しようとすると、同じ問題が発生しrewordます。

*編集#3 *

git config --listGoZonerによって要求された、(わずかに匿名化された)の出力は次のとおりです。

user.name=My Name
user.email=email@example.com
push.default=upstream
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
remote.origin.url=git@github.com:someGitHubAccount/Apps.git
branch.master.remote=origin
branch.master.merge=refs/heads/master
branch.deploy.remote=origin
branch.deploy.merge=refs/heads/deploy
...*more branches that look similar*
4

6 に答える 6

2

または、現在のコミットの親に対してインタラクティブなリベースを実行することもできます

git rebase -i head~

次にreword、コミットメッセージを変更するオプションを選択します。

于 2013-02-27T18:19:53.650 に答える
2

コミット時にトリガーするカスタムフックがないかどうかを確認します。

于 2013-04-25T07:05:59.340 に答える
1

するgit stash。次に、実行しますgit commit --amend。その後、行いますgit stash pop

于 2013-02-27T18:32:19.527 に答える
1

git commit --amendgit commit古いコミットをリサイクルするのと同じように機能します。つまり、これが意味するのは、実際にインデックスにいくつかの変更があり、コミットする準備ができていることを期待するということです。

したがって、自分someFile.jsを含める場合は、git add static/js/someFile.js最初に実行します。追跡されていないファイルも追跡する場合は、を使用してそれも追加しますgit add some/other/file

于 2013-02-27T18:10:19.713 に答える
1

試してみてくださいgit commit --amend --only。それでもうまくいかない場合は、試してみてくださいgit stash; git commit --amend ; git stash pop。ここであなたがどのような状態にあるのかわかりません。

于 2013-02-27T18:13:12.633 に答える
1

変更された追跡されていないファイルがある場合とない場合の両方で、私のために機能します。

$ echo 'a' > a; git add -A; git commit -m 'a'
$ echo 'b' > b; git add -A; git commit -m 'b'

$ git log --oneline
63f2dd1 b
a0b364a a
$ git commit --amend
$ git log --oneline
d4cdeb7 bxx            # changed the commit message
a0b364a a

$ ed a # edit 'a'
$ git status
# On branch master
# 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:   a
#
no changes added to commit (use "git add" and/or "git commit -a")

$ git commit --amend
$ git log --oneline
2d20e6e bxxyy           # changed the commit message again
a0b364a a

$ mkdir foo; echo 'c' > foo/c
$ git status
# On branch master
# 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:   a
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   foo/
no changes added to commit (use "git add" and/or "git commit -a")

$ git commit --amend
ebg@ebg(31)$ git log --oneline
09c1b26 bxxyyzz
a0b364a a
于 2013-04-23T21:53:52.057 に答える