Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Git Best Practices Guide

You're reading from   Git Best Practices Guide Master the best practices of Git with the help of real-time scenarios to maximize team efficiency and workflow

Arrow left icon
Product type Paperback
Published in Nov 2014
Publisher
ISBN-13 9781783553730
Length 102 pages
Edition 1st Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
PIDOUX Eric PIDOUX Eric
Author Profile Icon PIDOUX Eric
PIDOUX Eric
Arrow right icon
View More author details
Toc

Rebase


As we just saw, the merge command combines the changes from two branches. The rebase command will take the changes from the first branch and apply them to the other branch.

In the rebase command do not merge commit!

The following diagram displays the current state of our repository. We have the master branch pointed on Commit 3 and a branch pointed to Commit 4:

Our goal is to rebase branch from master, so we need to checkout on master and rebase it:

Erik@local:~/webproject$ git checkout branch
Erik@local:~/webproject$ git rebase master

The rebase command can be used if you want to get a feature (commits) from one branch to another and be sure to be close to the tip of the upstream branch. As we just saw, the command applies the changes from the branch called branch to the master branch.

In this schema, commit 4 is applied on master by using the name commit4bis, and the original commit 4 is deleted by the garbage collector.

The --interactive option will stop after each commit to change...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £13.99/month. Cancel anytime
Visually different images