{"thread":{"id":"43899","subject":"Editing a typo in the message given to \"git commit\"","startedAt":"2016-08-21T15:19:50Z","lastAt":"2016-08-22T19:02:31Z","messageCount":4,"participants":["norm@dad.org","Pranit Bauva","Eric Wong","Jakub Narębski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"299821","messageId":"201608211519.u7LFJiMR090069@shell1.rawbw.com","threadId":"43899","inReplyTo":null,"subject":"Editing a typo in the message given to \"git commit\"","fromName":"","fromEmail":"norm@dad.org","sentAt":"2016-08-21T15:19:43Z","receivedAt":"2016-08-21T15:19:50Z","isPatch":false,"sender":{"key":"norm@dad.org","avatar":null},"body":"I am learning how to use git. I would like to know:\n\nHow can I correct a typo in the message I gave to an old \"git commit\"? I see\nthat the typo occurs in exactly two files in .git:\n\n.git/logs/refs/heads/master\n.git/logs/HEAD\n\n/usr/bin/file says that they are both ASCII English text. So I could just\nhand edit them. But that seems somehow sacrilegious and might break git.\n\n    Norman Shapiro\n"},{"id":"299822","messageId":"CAFZEwPP=d6fN4MC09JGm4neY5MuXv1JBzx87HC+8=XjEp=DS_w@mail.gmail.com","threadId":"43899","inReplyTo":"201608211519.u7LFJiMR090069@shell1.rawbw.com","subject":"Re: Editing a typo in the message given to \"git commit\"","fromName":"Pranit Bauva","fromEmail":"pranit.bauva@gmail.com","sentAt":"2016-08-21T15:32:17Z","receivedAt":"2016-08-21T15:32:48Z","isPatch":false,"sender":{"key":"pranit.bauva@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2959938?v=4"},"body":"Hey Norman,\n\nOn Sun, Aug 21, 2016 at 8:49 PM,  <norm@dad.org> wrote:\n> I am learning how to use git. I would like to know:\n>\n> How can I correct a typo in the message I gave to an old \"git commit\"? I see\n> that the typo occurs in exactly two files in .git:\n>\n> .git/logs/refs/heads/master\n> .git/logs/HEAD\n>\n> /usr/bin/file says that they are both ASCII English text. So I could just\n> hand edit them. But that seems somehow sacrilegious and might break git.\n\nMessages to commits aren't just stored in these two files.\nHand editing them will definitely break git and its highly advisable\nnot to do that. In fact, for beginners its highly recommended to never\nvisit the \".git\" folder. What you need in this case is `git-rebase\n-i`. Using that you can go to the commit where you want to edit the\nmessage and mark it as \"reword\". Also if you want to make some\nmodifications in the code, then you can mark it as \"edit\". Try `man\ngit-rebase` for more info on the command.\n\nAlso on a side note: This is a developer's mailing list. Please try to\nuse the user's mailing list[1] for doubts. But if you have a doubt as\nto why this commands functions in a particular way (in which you think\nit should not) or you find a possible bug then feel free to discuss it\non this mailing list. Also to save other people's time, first search\nfor the doubt in the archives or google about it.\n\n[1]: https://groups.google.com/forum/#!forum/git-users\n\nRegards,\nPranit Bauva\n"},{"id":"299826","messageId":"20160821212927.GA8516@dcvr","threadId":"43899","inReplyTo":"CAFZEwPP=d6fN4MC09JGm4neY5MuXv1JBzx87HC+8=XjEp=DS_w@mail.gmail.com","subject":"Re: Editing a typo in the message given to \"git commit\"","fromName":"Eric Wong","fromEmail":"e@80x24.org","sentAt":"2016-08-21T21:29:27Z","receivedAt":"2016-08-21T21:29:39Z","isPatch":false,"sender":{"key":"e@80x24.org","avatar":null},"body":"Pranit Bauva <pranit.bauva@gmail.com> wrote:\n> On Sun, Aug 21, 2016 at 8:49 PM,  <norm@dad.org> wrote:\n> > I am learning how to use git. I would like to know:\n> >\n> > How can I correct a typo in the message I gave to an old \"git commit\"? I see\n> > that the typo occurs in exactly two files in .git:\n> >\n> > .git/logs/refs/heads/master\n> > .git/logs/HEAD\n> >\n> > /usr/bin/file says that they are both ASCII English text. So I could just\n> > hand edit them. But that seems somehow sacrilegious and might break git.\n> \n> Messages to commits aren't just stored in these two files.\n> Hand editing them will definitely break git and its highly advisable\n> not to do that. In fact, for beginners its highly recommended to never\n> visit the \".git\" folder. What you need in this case is `git-rebase\n> -i`. Using that you can go to the commit where you want to edit the\n> message and mark it as \"reword\". Also if you want to make some\n> modifications in the code, then you can mark it as \"edit\". Try `man\n> git-rebase` for more info on the command.\n\nAgreed.  I use \"git commit --amend\" if it's the latest commit;\nsaves typing.  Definitely don't edit anything in .git/logs/ by\nhand.\n\n> Also on a side note: This is a developer's mailing list. Please try to\n> use the user's mailing list[1] for doubts. But if you have a doubt as\n> to why this commands functions in a particular way (in which you think\n> it should not) or you find a possible bug then feel free to discuss it\n> on this mailing list. Also to save other people's time, first search\n> for the doubt in the archives or google about it.\n\nI disagree with this being a developer's-only list and pointing\nusers to a separate list.  Every git user is a potential\ndeveloper (especially for a tool aimed for managing source).\nOften user questions turn into bug reports aimed at\ndevelopers.\n\nNothing in our manpages even mentions this git-users list.\n\n> [1]: https://groups.google.com/forum/#!forum/git-users\n\n\nKeep in mind I have a strong anti-centralization bias and\nGoogle is a big basket, here.  I'll let their history of\ndiscontinuing services like Google Reader, Google Code,\netc. speak for itself :)\n"},{"id":"299862","messageId":"8b0cf1e5-41c9-4b5a-0baf-4996c45d31ef@gmail.com","threadId":"43899","inReplyTo":"201608211519.u7LFJiMR090069@shell1.rawbw.com","subject":"Re: Editing a typo in the message given to \"git commit\"","fromName":"Jakub Narębski","fromEmail":"jnareb@gmail.com","sentAt":"2016-08-22T19:02:05Z","receivedAt":"2016-08-22T19:02:31Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"W dniu 21.08.2016 o 17:19, norm@dad.org pisze:\n\n> I am learning how to use git. I would like to know:\n> \n> How can I correct a typo in the message I gave to an old \"git commit\"? I see\n> that the typo occurs in exactly two files in .git:\n> \n> .git/logs/refs/heads/master\n> .git/logs/HEAD\n> \n> /usr/bin/file says that they are both ASCII English text. So I could just\n> hand edit them. But that seems somehow sacrilegious and might break git.\n\nAs the pathname suggests, those two files are only *logs*, to be more\nexact these store so called reflogs, which allow for example use @{1}\nfor previous position of current branch in your local repository, or\n\"git checkout -\" (or \"git checkout @{-1}\") to go back to previous branch.\nYou can edit them (just take care to not touch the rest of line / file),\nbut it wouldn't change what is in your history, what 'git log' would show.\n\nIf the typo was in the last commit you have created, the simplest solution\nis to use 'git commit --amend' (assuming that you didn't 'git add' any files\nin meantime).\n\nIf it was something few commits back, you need to use 'git rebase --interactive',\nstarting from the commit before the one you want to change.  Then you need\nto change 'pick' to 'reword', as described in instruction sheet for interactive\nrebase. \n\n\nP.S. Good source of finding answers is StackOverflow[1], and new (and in beta)\nStackOverflow Documentation\n\n[1]: http://stackoverflow.com/questions/tagged/git \n[2]: http://stackoverflow.com/documentation/git\n\nThere is also #git channel on FreeNode[3]\n\n[3]: ircs://chat.freenode.net:6697/git\n"}]}