From: "Jakub Narębski" <jnareb@gmail.com>
To: Norman Shapiro <norm@dad.org>, git@vger.kernel.org
Subject: Re: Editing a typo in the message given to "git commit"
Date: Mon, 22 Aug 2016 21:02:05 +0200 [thread overview]
Message-ID: <8b0cf1e5-41c9-4b5a-0baf-4996c45d31ef@gmail.com> (raw)
In-Reply-To: <201608211519.u7LFJiMR090069@shell1.rawbw.com>
W dniu 21.08.2016 o 17:19, norm@dad.org pisze:
> I am learning how to use git. I would like to know:
>
> How can I correct a typo in the message I gave to an old "git commit"? I see
> that the typo occurs in exactly two files in .git:
>
> .git/logs/refs/heads/master
> .git/logs/HEAD
>
> /usr/bin/file says that they are both ASCII English text. So I could just
> hand edit them. But that seems somehow sacrilegious and might break git.
As the pathname suggests, those two files are only *logs*, to be more
exact these store so called reflogs, which allow for example use @{1}
for previous position of current branch in your local repository, or
"git checkout -" (or "git checkout @{-1}") to go back to previous branch.
You can edit them (just take care to not touch the rest of line / file),
but it wouldn't change what is in your history, what 'git log' would show.
If the typo was in the last commit you have created, the simplest solution
is to use 'git commit --amend' (assuming that you didn't 'git add' any files
in meantime).
If it was something few commits back, you need to use 'git rebase --interactive',
starting from the commit before the one you want to change. Then you need
to change 'pick' to 'reword', as described in instruction sheet for interactive
rebase.
P.S. Good source of finding answers is StackOverflow[1], and new (and in beta)
StackOverflow Documentation
[1]: http://stackoverflow.com/questions/tagged/git
[2]: http://stackoverflow.com/documentation/git
There is also #git channel on FreeNode[3]
[3]: ircs://chat.freenode.net:6697/git
prev parent reply other threads:[~2016-08-22 19:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-21 15:19 Editing a typo in the message given to "git commit" norm
2016-08-21 15:32 ` Pranit Bauva
2016-08-21 21:29 ` Eric Wong
2016-08-22 19:02 ` Jakub Narębski [this message]
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=8b0cf1e5-41c9-4b5a-0baf-4996c45d31ef@gmail.com \
--to=jnareb@gmail.com \
--cc=git@vger.kernel.org \
--cc=norm@dad.org \
/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).