From: Thomas Rast <trast@student.ethz.ch>
To: Parag Kalra <paragkalra@gmail.com>
Cc: Konstantin Khomoutov <flatworm@users.sourceforge.net>,
<git@vger.kernel.org>
Subject: Re: Basic Git Questions
Date: Mon, 20 Dec 2010 00:15:16 +0100 [thread overview]
Message-ID: <201012200015.17203.trast@student.ethz.ch> (raw)
In-Reply-To: <20101219230839.GM3264@localhost.localdomain>
Konstantin Khomoutov wrote:
> > 2. Also sometime when the code is committed, I realize that I have
> > forgot to change or add a file. Is there a way we can we commit a file
> > to existing commit number with git log showing only the old git commit
> > number and not creating a new one for the last commit.
> `git commit --amend` does exactly that -- amends the last commit
> (pointed by the HEAD ref).
Let me add that you can fundamentally not edit any git object in any
way without its ID (hash, sha1, whatever you call it) changing. All
methods of "changing" commits, like amend, rebase, filter-branch
etc. always create a new object. The trick is that, especially with
amend, the branch is also changed to point to the new one, so unless
you have already merged or pushed that commit, this is as close to
"changing" as it gets.
Tv put this more eloquently as: "you can never change; you can only
rewrite and forget".
If you *have* merged or pushed the commit, you shouldn't rewrite
history. It's not that hard to fix up your local merges, but if you
have pushed the history and others have started working with it, it's
*very* annoying for them.
--
Thomas Rast
trast@{inf,student}.ethz.ch
next prev parent reply other threads:[~2010-12-19 23:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-19 22:32 Basic Git Questions Parag Kalra
2010-12-19 23:08 ` Konstantin Khomoutov
2010-12-19 23:15 ` Thomas Rast [this message]
-- strict thread matches above, loose matches on Subject: below --
2010-12-20 19:21 George Spelvin
2010-12-21 2:59 ` Adam Kellas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201012200015.17203.trast@student.ethz.ch \
--to=trast@student.ethz.ch \
--cc=flatworm@users.sourceforge.net \
--cc=git@vger.kernel.org \
--cc=paragkalra@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).