[Git] --amend

Change a Commit Message that Hasn't Been Pushed Yet

If you make a mistake in a commit message but HAVEN'T pushed it yet, you can change that commit message with --amend:

git commit --amend -m "New message"

This won't change any of the files in your commit - but will rewrite the commit with the new message.

Add More Files and Changes to a Commit Before Pushing

To add more files to the most recent commit, we can add them to the staging area with:

git add -A

and then rewrite the most recent commit to include them with:

git commit --amend -m "My new message"

Caution: only do this BEFORE you've pushed the commits - otherwise you will be re-writing history for people who may have already pulled down the old commits.

 

posted @   Zhentiw  阅读(173)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
历史上的今天:
2018-12-12 [Algorithms] Queue & Priority Queue
2017-12-12 [Python] Reuse Code in Multiple Projects with Python Modules
2016-12-12 [D3] Load and Inspect Data with D3 v4
2016-12-12 [Now] Update an application hosted with Zeit’s Now
2016-12-12 [JS Compose] 1. Refactor imperative code to a single composed expression using Box
2014-12-12 [MongoDB] Insert, find -- 1
点击右上角即可分享
微信分享提示