GNU/Linux ◆ xterm-256color ◆ bash 1513 views

Lets see how git-rebase can be used to merge two commits.

I have git tree where last two commit are nearly the same. I need to merge them together::

b835d5bd21cc - Sachin Patil, 34 minutes ago : Fixed: No timestamp while system reservation 7a8a7f1cee9e - Sachin Patil, 7 days ago : Fixed: No timestamp while system reservation

  • pick stands for use the commit as the base commit

  • squash merge that commit(s) to base commit

  • Lets pick 7a8a7f1cee9e as a base commint and merge b835d5bd21cc to it

  • Press s to squash b835d5bd21cc

  • Now save-quit the buffer(This depends on the editor you use).

  • After saving changes, the new buffer gives you a chance to enter or alter commit message. When done with commit message, save & quit the buffer.

  • Finally check out the new tree, you should have single commit. Notice new commit hash