All of lore.kernel.org
 help / color / mirror / Atom feed
* Editing a typo in the message given to "git commit"
@ 2016-08-21 15:19 norm
  2016-08-21 15:32 ` Pranit Bauva
  2016-08-22 19:02 ` Jakub Narębski
  0 siblings, 2 replies; 4+ messages in thread
From: norm @ 2016-08-21 15:19 UTC (permalink / raw)
  To: git; +Cc: norm

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.

    Norman Shapiro

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Editing a typo in the message given to "git commit"
  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
  1 sibling, 1 reply; 4+ messages in thread
From: Pranit Bauva @ 2016-08-21 15:32 UTC (permalink / raw)
  To: Norman Shapiro; +Cc: Git List

Hey Norman,

On Sun, Aug 21, 2016 at 8:49 PM,  <norm@dad.org> wrote:
> 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.

Messages to commits aren't just stored in these two files.
Hand editing them will definitely break git and its highly advisable
not to do that. In fact, for beginners its highly recommended to never
visit the ".git" folder. What you need in this case is `git-rebase
-i`. Using that you can go to the commit where you want to edit the
message and mark it as "reword". Also if you want to make some
modifications in the code, then you can mark it as "edit". Try `man
git-rebase` for more info on the command.

Also on a side note: This is a developer's mailing list. Please try to
use the user's mailing list[1] for doubts. But if you have a doubt as
to why this commands functions in a particular way (in which you think
it should not) or you find a possible bug then feel free to discuss it
on this mailing list. Also to save other people's time, first search
for the doubt in the archives or google about it.

[1]: https://groups.google.com/forum/#!forum/git-users

Regards,
Pranit Bauva

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Editing a typo in the message given to "git commit"
  2016-08-21 15:32 ` Pranit Bauva
@ 2016-08-21 21:29   ` Eric Wong
  0 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2016-08-21 21:29 UTC (permalink / raw)
  To: Pranit Bauva; +Cc: Norman Shapiro, Git List

Pranit Bauva <pranit.bauva@gmail.com> wrote:
> On Sun, Aug 21, 2016 at 8:49 PM,  <norm@dad.org> wrote:
> > 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.
> 
> Messages to commits aren't just stored in these two files.
> Hand editing them will definitely break git and its highly advisable
> not to do that. In fact, for beginners its highly recommended to never
> visit the ".git" folder. What you need in this case is `git-rebase
> -i`. Using that you can go to the commit where you want to edit the
> message and mark it as "reword". Also if you want to make some
> modifications in the code, then you can mark it as "edit". Try `man
> git-rebase` for more info on the command.

Agreed.  I use "git commit --amend" if it's the latest commit;
saves typing.  Definitely don't edit anything in .git/logs/ by
hand.

> Also on a side note: This is a developer's mailing list. Please try to
> use the user's mailing list[1] for doubts. But if you have a doubt as
> to why this commands functions in a particular way (in which you think
> it should not) or you find a possible bug then feel free to discuss it
> on this mailing list. Also to save other people's time, first search
> for the doubt in the archives or google about it.

I disagree with this being a developer's-only list and pointing
users to a separate list.  Every git user is a potential
developer (especially for a tool aimed for managing source).
Often user questions turn into bug reports aimed at
developers.

Nothing in our manpages even mentions this git-users list.

> [1]: https://groups.google.com/forum/#!forum/git-users


Keep in mind I have a strong anti-centralization bias and
Google is a big basket, here.  I'll let their history of
discontinuing services like Google Reader, Google Code,
etc. speak for itself :)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Editing a typo in the message given to "git commit"
  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-22 19:02 ` Jakub Narębski
  1 sibling, 0 replies; 4+ messages in thread
From: Jakub Narębski @ 2016-08-22 19:02 UTC (permalink / raw)
  To: Norman Shapiro, git

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-08-22 19:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.