I don’t really understand what happens if I check out an old commit, do some modifications, and commit using git commit --amend.
Will that change automatically propagate to future commits? How does it work?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In git, commits are just objects. When you
git commit --amend, you’re just creating a new commit with the same parent. Initially that looks like this:Now you amend
C, creating a new commitD:The old
Cis still there for the moment. However, it is no longer referenced by any branch, so the next time a garbage collection occurs, it’s going to be swept away.