{"thread":{"id":"43316","subject":"Re: changing log entries","startedAt":"2006-12-13T23:08:01Z","lastAt":"2006-12-15T08:48:44Z","messageCount":5,"participants":["Shawn Pearce","Jakub Narebski","Andy Parkins","Jon Masters"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"298451","messageId":"1166051281.1808.1.camel@jcm.boston.redhat.com","threadId":"43316","inReplyTo":null,"subject":"changing log entries","fromName":"Jon Masters","fromEmail":"jcm@redhat.com","sentAt":"2006-12-13T23:08:01Z","receivedAt":"2006-12-13T23:08:01Z","isPatch":false,"sender":{"key":"jcm@redhat.com","avatar":null},"body":"Hi,\n\nSo I figured out that the problem with \"Can't lock ref\" was down to not\nhaving set one of the scripts executable on the http server. Great.\n\nAnyway, now I would like to change an existing log entry to make it a\nbit cleaner (read: add a first line that's under 80 characters). What's\nthe best way to change an existing log entry for a commit?\n\nJon.\n\n"},{"id":"296395","messageId":"elq1qk$4ie$2@sea.gmane.org","threadId":"43316","inReplyTo":"1166051281.1808.1.camel@jcm.boston.redhat.com","subject":"Re: changing log entries","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-12-13T23:22:17Z","receivedAt":"2006-12-13T23:22:17Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Jon Masters wrote:\n\n> Anyway, now I would like to change an existing log entry to make it a\n> bit cleaner (read: add a first line that's under 80 characters). What's\n> the best way to change an existing log entry for a commit?\n\nSee top two answers in http://git.or.cz/gitwiki/GitTips\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n\n"},{"id":"294335","messageId":"20061213232452.GE32568@spearce.org","threadId":"43316","inReplyTo":"1166051281.1808.1.camel@jcm.boston.redhat.com","subject":"Re: changing log entries","fromName":"Shawn Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-12-13T23:24:52Z","receivedAt":"2006-12-13T23:24:52Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Jon Masters <jcm@redhat.com> wrote:\n> Hi,\n> \n> So I figured out that the problem with \"Can't lock ref\" was down to not\n> having set one of the scripts executable on the http server. Great.\n> \n> Anyway, now I would like to change an existing log entry to make it a\n> bit cleaner (read: add a first line that's under 80 characters). What's\n> the best way to change an existing log entry for a commit?\n\nIf its the most recent commit on that branch, \"git commit --amend\".\n\nOtherwise dump out the branch to patches with git format-patch,\namend the commit in question, then replay the patches with git am.\n\nOr use StGIT to uncommit the changes, pop them off, fix the commit,\nthen repush the patches and recommit in StGIT.\n\n\nNote that any of the above methods change the SHA1 of that commit\nand every commit which follows it on that branch.  Consequently it\nis generally considered to be impolite to edit commits without\nwarning which you have already published, as another person may be\nbasing their own work off that commit.\n\n-- \n"},{"id":"296607","messageId":"200612141037.35061.andyparkins@gmail.com","threadId":"43316","inReplyTo":"1166051281.1808.1.camel@jcm.boston.redhat.com","subject":"Re: changing log entries","fromName":"Andy Parkins","fromEmail":"andyparkins@gmail.com","sentAt":"2006-12-14T10:37:34Z","receivedAt":"2006-12-14T10:37:34Z","isPatch":false,"sender":{"key":"andyparkins@gmail.com","avatar":null},"body":"On Wednesday 2006 December 13 23:08, Jon Masters wrote:\n\n> Anyway, now I would like to change an existing log entry to make it a\n> bit cleaner (read: add a first line that's under 80 characters). What's\n> the best way to change an existing log entry for a commit?\n\nIf it's HEAD you want to change:\n git-commit --amend\n\nIf it's not, it's a bit harder.  You could pull each commit out as a patch and \napply them again later after a git-reset.  However, git has a tool for \nautomating a lot of that:  git-rebase.  man git-rebase has some excellent \nexamples.\n\n * -- A -- B -- C (master)\n\nLet's say you want to edit A; make a new branch at A:\n\n$ git branch temp-edit-branch master^^\n \n * -- A (temp-edit-branch)\n       \\\n        B -- C (master)\n\nEdit A with git-commit --amend.  This makes a new A, A' that has the new \ncommit message:\n\n * -- A' (temp-edit-branch)\n  \\\n   A -- B -- C (master)\n\nThen you switch to \"master\" and rebase master onto temp-edit-branch; you can \nthen delete temp-edit-branch\n\n$ git-checkout master\n$ git-rebase temp-edit-branch\n$ git branch -D temp-edit-branch\n\n * -- A' -- B' -- C' (master)\n  \\\n   A -- B -- C\n\nNote that A-B-C are now dangling commits; a git-prune would be needed to clean \nthem out of the repository.\n\nThe important thing to realise is that you can never really edit a commit.  \nThe best you can do is reapply it.  In this example, the fact that B' makes \nthe same change as B is irrelevant - they are two separate commits.\n\nNote: this is only workable if you haven't pushed this branch to another \nrepository.  The other repository would retain the original A--B--C branch \nand you will get \"won't fast forward\" errors if you try to push the \nnew \"A'--B'--C'\" branch.\n\n\nAndy\n-- \nDr Andy Parkins, M Eng (hons), MIEE\n"},{"id":"294537","messageId":"eltncn$te5$1@sea.gmane.org","threadId":"43316","inReplyTo":"200612141037.35061.andyparkins@gmail.com","subject":"Re: changing log entries","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-12-15T08:48:44Z","receivedAt":"2006-12-15T08:48:44Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Andy Parkins wrote:\n\n> On Wednesday 2006 December 13 23:08, Jon Masters wrote:\n> \n>> Anyway, now I would like to change an existing log entry to make it a\n>> bit cleaner (read: add a first line that's under 80 characters). What's\n>> the best way to change an existing log entry for a commit?\n> \n> If it's HEAD you want to change:\n>  git-commit --amend\n> \n> If it's not, it's a bit harder.  You could pull each commit out as a patch and \n> apply them again later after a git-reset.  However, git has a tool for \n> automating a lot of that:  git-rebase.  man git-rebase has some excellent \n> examples.\n> \n>  * -- A -- B -- C (master)\n> \n> Let's say you want to edit A; make a new branch at A:\n> \n> $ git branch temp-edit-branch master^^\n>  \n>  * -- A (temp-edit-branch)\n>        \\\n>         B -- C (master)\n> \n> Edit A with git-commit --amend.  This makes a new A, A' that has the new \n> commit message:\n> \n>  * -- A' (temp-edit-branch)\n>   \\\n>    A -- B -- C (master)\n> \n> Then you switch to \"master\" and rebase master onto temp-edit-branch; you can \n> then delete temp-edit-branch\n> \n> $ git-checkout master\n> $ git-rebase temp-edit-branch\n\nTheoretically you should do\n\n$ git rebase --onto temp-edit-branch master^^ master\n\nbut thanks to automatic detection that patch is already applied the\nabove also should work. Well, unless you edit the commit so much\nthat git does not recognize it as the same commit...\n\n> $ git branch -D temp-edit-branch\n> \n>  * -- A' -- B' -- C' (master)\n>   \\\n>    A -- B -- C\n\n...in which case \"git rebase temp-edit-branch master\" would give you\n\n  * -- A' --A* -- B* -- C* (master)\n   \\\n    A -- B -- C\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n\n"}]}