Rewriting Commit Messages in Git

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so somebody just now asked a question on the acrl tech connect blog about rewriting a commit message and get after you've already committed and I thought that'd be a good topic for a little screencast so that's what I'm going to do I'm in this git repository and I have three commits here but in the very last one that I did you can see that I misspelled the word bug so to fix that there's a really handy flag that you can pass to commit where you just put - - amend and that'll let you edit the last commit message so then you do em and put in a new message so I can just go ahead and fix that and when I do indeed that commit message gets fixed so that's great if you just want to edit the very last one but what if I wanted to edit this second commit in there sweet new feature added well there's a very powerful command that does a whole lot more than just this and there are other ways to do this probably but what I do is I do it rebase and then I that stands for interactive so it's actually we're going to see an editor open up here and we'll have some choices that we can make and then you do head Tilda and the number of commits back that you want to do changes to so if it was two commits ago I do - if I wanted to change that very first commit I can do three but let's let's just do two for now and what I'm given is a pretty complicated interface so my editor opened up it may be different for you depending on your environment for me I'm looking at them here and you have different commands that you can do to each of these commits that are listed so you can do P and pick and reword and edit and squash and fix up those are all the things you can do and clearly for this situation I just need reword so that's what I do i do reword there and then if I kind of write and close in in vim I'm given suddenly another editing interface opens up and this is the one that allows me to change that message so I can write in something new here and so that should change the message and you can see that this little get gives us some information here and it said hey we're rebasing and now if I do get log indeed awesome new feature added is the second message so that was a couple ways that you can change commit messages from things that happened in the past
Info
Channel: Eric Phetteplace
Views: 35,063
Rating: 4.9376945 out of 5
Keywords: Git (Revision Control Software), Rebase, Commit, History, Rewrite
Id: 4YjKY0u9Z6I
Channel Id: undefined
Length: 2min 35sec (155 seconds)
Published: Tue Mar 04 2014
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.