Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git rebase - what's the difference between 'edit' and 'reword'

What's the difference between edit and reword when you do a git rebase?

I'm going through some docs which say this:

Replace pick with: - edit to mark a commit for amending. - reword to change the log message. 
like image 648
Snowcrash Avatar asked May 12 '15 15:05

Snowcrash


People also ask

What is git rebase edit?

The interactive rebase gives you a script that it's going to run. It will start at the commit you specify on the command line ( HEAD~3 ) and replay the changes introduced in each of these commits from top to bottom. It lists the oldest at the top, rather than the newest, because that's the first one it will replay.

Does git rebase rewrite history?

To modify older or multiple commits, you can use git rebase to combine a sequence of commits into a new base commit. In standard mode, git rebase allows you to literally rewrite history — automatically applying commits in your current working branch to the passed branch head.


2 Answers

  • "reword" allows you to change ONLY the commit message, NOT the commit contents
  • "edit" allows you to change BOTH commit contents AND commit message (the mechanism by which git allows you to edit the commit contents is by "pausing" the rebase; so you can amend the commit)

reference : The git-rebase documentation says this:

  • edit : By replacing the command "pick" with the command "edit", you can tell git rebase to stop after applying that commit, so that you can edit the files and/or the commit message, amend the commit, and continue rebasing.
  • reword : If you just want to edit the commit message for a commit, replace the command "pick" with the command "reword".
like image 76
Chris Maes Avatar answered Oct 03 '22 00:10

Chris Maes


edit will pause the rebase entirely, allowing you to change files in the commit and/or the commit message.

reword will simply open an editor to let you change the commit message only.

like image 20
SLaks Avatar answered Oct 03 '22 02:10

SLaks