Rebase

WHAT IT IS:

  • Rebasing is the process of moving or combining a sequence of confirmations for a new basic confirmation.

WHAT'S IT FOR?

  • Edit previous commit messages;
  • Combine multiple commits into one;
  • Delete or reverse commits that are no longer needed.

It's a very interesting command, because you can make changes to your commit history, such as:

# Commands:
# p, pick <commit>= use commit
# r, reword <commit>= use commit, but edit the commit message
# e, edit <commit>= use commit, but stop for amending
# s, squash <commit>= use commit, but meld into previous commit
# f, fixup <commit>= like "squash", but discard this commit's log message
# x, exec <command>= run command (the rest of the line) using shell
# b, break = stop here (continue rebase later with 'git rebase --continue')
# d, drop <commit>= remove commit
# l, label <label>= label current HEAD with a name
# t, reset <label>= reset HEAD to a label
# m, merge [-C <commit>| -c <commit>] <label>[# <oneline>]
# . 	create a merge commit using the original merge commit's
# . 	message (or the oneline, if no original merge commit was
# . 	specified). Use -c <commit>to reword the commit message.

Note: Git explains each command

Remember that command we use to join branches, you can do it interactively (-i), and so you'll call this screen with many command options:

Bash '''Bash' $ git rebase -i "branch name"


The rebase also gives a lot of options, let's assume that you have regretted committing, or some past commit has gotten bad, or want to rename, join commits. **Git rebase can do all this through this command**

Bash '''Bash'
$ git rebase -i HEAD~"name ordering to where you want to see your commits"

Example:

git rebase -i HEAD~7

Why 7: Why git pick up the last 7 that were added to the stack.

pick 5a45c7b adding git ignore
pick 44013a9 fifth commit
pick 893a770 Creating a new feature
pick a355932 commit sixth'
pick 0418ff2 modifying files
pick a492cf0 Adding stash
pick c302ac4 setimo commit
# Rebase f8473e3.. c302ac4 onto A355932 (7 commands)
# 
#Commands:

# p, pick <commit>= use commit
# r, reword <commit>= use commit, but edit the commit message
# e, edit <commit>= use commit, but stop for amending
# s, squash <commit>= use commit, but meld into previous commit
# f, fixup <commit>= like "squash", but discard this commit's log message
# x, exec <command>= run command (the rest of the line) using shell
# b, break = stop here (continue rebase later with 'git rebase --continue')
# d, drop <commit>= remove commit
# l, label <label>= label current HEAD with a name
# t, reset <label>= reset HEAD to a label
# m, merge [-C <commit>| -c <commit>] <label>[# <oneline>]
# .       create a merge commit using the original merge commit'
# .       message (or the oneline, if no original merge commit was
# .       specified). Use -c <commit>to reword the commit message.
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.

Note: The rebase command is pretty cool, but be careful, it's very easy to get lost or get confused.

 

results matching ""

    No results matching ""