Gitコミット著者を変える方法?
5253 ワード
Gitのマスターになることは複雑であるかもしれません、Gitが我々に提供するいくつかのオプションがあり、それらのいくつかがチームが我々が今取り組んでいるプロジェクトのプロセスを定義する規則に基づいて使用される必要があるので.
いくつかの時点で誰もがgitの助けを必要としているので、主なアイデアは、Gitで持つことができるヒントや一般的な問題を再コンパイルしようとすることです.
このポストでは、エラーが間違ったGitユーザー、電子メールまたはそのような何かで犯された場合に、あなたが何をすることができるかについて見ます.
これは最も簡単な景色ですが、基本的には、端末の次のコマンドを実行する必要があります.
コミットがリモートでプッシュされた場合、余分なコミットを実行する必要があります.
これらのケースでは、最良のオプションは、あなたが今取り組んでいるブランチのベースを適用することです.まず第一に、あなたが変更したい枝にいることを確認してください.
たとえば、私たちには、機能/テストと呼ばれる枝があります、そして、最後の2つのコミットは間違ったメールで押されました.それで、コミットの著者情報を変更する必要があります.
その後、同様のものが表示されます
コマンド
挿入モードに挿入する
ESC :挿入モード の終了
WQ :書き込みと終了
Q : を終了しました
その後、gitはrebaseを処理します、そして、あなたが選んだコミットでは、ピックはメッセージのような何かを表示されます
コミットがリモートでプッシュされた場合には、次のコマンドを
ご存知のように、私たちはいくつかの簡単なコマンドでコミットの著者を変更することができますので、その問題をafront場合に進んでください.私はあなたが本当にこの記事を見つける願っています.私はこのポストをあなたのコメントと推薦に基づいて更新します.ありがとう👍
いくつかの時点で誰もがgitの助けを必要としているので、主なアイデアは、Gitで持つことができるヒントや一般的な問題を再コンパイルしようとすることです.
このポストでは、エラーが間違ったGitユーザー、電子メールまたはそのような何かで犯された場合に、あなたが何をすることができるかについて見ます.
変更直前コミット
これは最も簡単な景色ですが、基本的には、端末の次のコマンドを実行する必要があります.
git commit --amend --author="<name> <email>" --no-edit
コミットはリモートでプッシュされた?
コミットがリモートでプッシュされた場合、余分なコミットを実行する必要があります.
git push -f origin <branch-name>
その後、ちょうどgit log
コマンドを行うことができますし、変更が適用された歴史を確認してください.コミット以上の変更
これらのケースでは、最良のオプションは、あなたが今取り組んでいるブランチのベースを適用することです.まず第一に、あなたが変更したい枝にいることを確認してください.
たとえば、私たちには、機能/テストと呼ばれる枝があります、そして、最後の2つのコミットは間違ったメールで押されました.それで、コミットの著者情報を変更する必要があります.
2c6eececec35ece0dc52c683de2dbc34553b283b
1c6eececec35ece0dc52c683de2dbc34553b283b
commit 2c6eececec35ece0dc52c683de2dbc34553b283b (HEAD -> feature/test, origin/feature/test)
Author: Brayan Arrieta <wrong-email>
Date: Tue Jun 22 16:06:10 2021 -0600
Feat: change some stuff
commit 1c6eececec35ece0dc52c683de2dbc34553b283b (HEAD -> feature/test, origin/feature/test)
Author: Brayan Arrieta <wrong-email>
Date: Tue Jun 22 16:04:10 2021 -0600
Feat: change server
commit 4d133f673250ed628e58371a8b246d68171fbbf9 (origin/master, origin/HEAD, master)
Merge: 144c453125 cb1ac7e774
Author: Other User <[email protected]>
Date: Tue Jun 22 13:40:43 2021 -0500
Merge branch 'feature/test2' into 'master'
まず最初に修正するには、次のコマンドで枝のベースを再実行する必要がありますgit rebase -i -p <previous-commit-id>
param以前のコミットIDでは、修正したいコミットの前に前のコミットIDを渡す必要があります.例えば、この場合、コマンドはgit rebase -i -p 4d133f673250ed628e58371a8b246d68171fbbf9
です.その後、同様のものが表示されます
pick 2c6eece Feat: change some stuff
pick 1c6eece Feat: change server
# Rebase 4d133f6..2c6eece onto 4d133f6 (4 commands)
#
# Commands:
# p, pick <commit> = use commit
# r, reword <commit> = use commit, but edit the commit message
# e, edit <commit> = use commit, but stop for amending
# s, squash <commit> = use commit, but meld into previous commit
# f, fixup <commit> = like "squash", but discard this commit's log message
# x, exec <commit> = run command (the rest of the line) using shell
# d, drop <commit> = remove commit
# l, label <label> = label current HEAD with a name
# t, reset <label> = reset HEAD to a label
# m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
# . create a merge commit using the original merge commit's
# . message (or the oneline, if no original merge commit was
# . specified). Use -c <commit> to reword the commit message.
#
# These lines can be re-ordered; they are executed from top to bottom.
#
".git/rebase-merge/git-rebase-todo" 28L, 1267C
その後、間違った作者がいるすべてのコミットがコミットリストにPかピックを持っていることを確認してください.挿入モードで入力するキーボードで何かを変更する必要がある場合は、変更、およびESCを適用します.その後、我々はちょうど入力する必要があります:私たちのキーボードのWQを保存する.コマンド
挿入モードに挿入する
ESC :挿入モード
WQ :書き込みと終了
Q :
その後、gitはrebaseを処理します、そして、あなたが選んだコミットでは、ピックはメッセージのような何かを表示されます
Stopped at 1c6eece... Feat: change server
You can amend the commit now, with
git commit --amend
Once you are satisfied with your changes, run
git rebase --continue
そのメッセージが表示されたら、著者を変更するか、またはコマンドgit rebase --continue
を続けてください.変更する場合は、次のコミットを実行する必要があります.git commit --amend --author="Brayan Arrieta <correct-email>" --no-edit
その後、次のコミットを続けるgit rebase --continue
言及する重要な何かは、言及される前のステップがピックオプションですべてのコミットに適用される必要があるということです.あなたのようなメッセージが表示されますSuccessfully rebased and updated refs/heads/feature/test.
その後、プッシュコマンドを実行する必要がありますgit push origin <branch-name>
コミットは、リモートでプッシュされた?
コミットがリモートでプッシュされた場合には、次のコマンドを
git push origin <branch-name>
コマンドの代わりに実行する必要があります.これは、修正を受けてブランチのGit履歴を変更します.git push -f origin <branch-name>
結論
ご存知のように、私たちはいくつかの簡単なコマンドでコミットの著者を変更することができますので、その問題をafront場合に進んでください.私はあなたが本当にこの記事を見つける願っています.私はこのポストをあなたのコメントと推薦に基づいて更新します.ありがとう👍
Reference
この問題について(Gitコミット著者を変える方法?), 我々は、より多くの情報をここで見つけました https://dev.to/brayanarrieta/how-to-change-the-git-commit-author-56mgテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol