Skip to main content

이 버전의 GitHub Enterprise Server는 다음 날짜에 중단됩니다. 2026-08-25. 지원되지 않는 릴리스는 지원되지 않습니다. 중요한 보안 문제에 대해서도 패치 릴리스가 이루어지지 않습니다. GitHub Enterprise Server의 향상된 성능, 향상된 보안 및 새로운 기능은 업그레이드 프로세스의 오버뷰 참조하세요. 업그레이드에 대한 도움이 필요하면 GitHub Enterprise 지원에 문의하세요.

Changing a commit message

Amend unclear, incorrect, or sensitive commit messages locally and push updated commits to GitHub, including steps for editing recent or older commits.

Rewriting the most recent commit message

Changing a commit message creates a new commit ID. If the commit has already been pushed, you must force push the rewritten history.

Commit has not been pushed online

If the commit only exists in your local repository, amend the commit message locally.

  1. On the command line, navigate to the repository that contains the commit you want to amend.

  2. Type git commit --amend and press Enter.

  3. In your text editor, edit the commit message, and save the commit.

  4. Push the commit to GitHub Enterprise Server 인스턴스.

Amending older or multiple commit messages

If you have already pushed the commit, use caution before rewriting history. Force pushing can disrupt collaborators who have based work on the old commits.

Changing the message of the most recently pushed commit

  1. Follow the steps in Commit has not been pushed online to amend the commit message.

  2. Force push over the old commit.

    git push --force-with-lease origin EXAMPLE-BRANCH
    

Changing the message of older or multiple commit messages

Use interactive rebase to change older or multiple commit messages.

  1. On the command line, navigate to the repository that contains the commits you want to amend.

  2. Start an interactive rebase for the last n commits.

    git rebase -i HEAD~n
    
  3. In the commit list, replace pick with reword before each commit message you want to change.

    pick e499d89 Delete CNAME
    reword 0c39034 Better README
    reword f7fde4a Change the commit message
    
  4. Save and close the commit list file.

  5. In each commit message file that opens, enter the new message, then save and close the file.

  6. Force push the rewritten history.

    git push --force-with-lease origin EXAMPLE-BRANCH
    

See Interactive mode in the Git manual.

경고

If a commit message included sensitive information, force pushing an amended commit might not remove the original commit from GitHub. Contact 사이트 관리자에게 문의 with the old commit ID to have it purged from the remote repository.

Further reading