< Return to Video

Rebase • GitHub & Git Foundations

  • Not Synced
    Git Rebase is the ability
    to take existing commits,
  • Not Synced
    and to place them on a branch
    that starts today.
  • Not Synced
    ♪ (jazzy theme music throughout) ♪
  • Not Synced
    Creating a branch is a tough decision.
  • Not Synced
    Start it today, or start it later?
  • Not Synced
    Well, some important fixes
    might be happening right now.
  • Not Synced
    So better wait until tomorrow.
  • Not Synced
    That difficult decision
    has gone away with Git.
  • Not Synced
    Start a branch whenever you like,
  • Not Synced
    and make it contain the changes
    that you intend to deliver.
  • Not Synced
    Focused on a particular feature,
  • Not Synced
    bug fix, or objective.
  • Not Synced
    What about wanting this to start
  • Not Synced
    at a later place in history,
  • Not Synced
    in order to incorporate those hot fixes
  • Not Synced
    that are going on to the master branch?
  • Not Synced
    No problem.
    Rebase to the rescue.
  • Not Synced
    Rebase, in its standard usage form,
  • Not Synced
    allows one branch to be relocated
    farther down the history track,
  • Not Synced
    meaning taking all of the changes
    that are isolated on your branch,
  • Not Synced
    and acting as if they happened after
  • Not Synced
    all of the modern work
    on the master branch.
  • Not Synced
    This accomplishes the same thing,
    but with cleaner history,
  • Not Synced
    than doing a reverse merge
  • Not Synced
    from the master branch
    to the feature branch.
  • Not Synced
    The same contents will be present
    in the feature branch,
  • Not Synced
    but without the complication of the merge,
  • Not Synced
    going into that feature branch,
    and recorded in its history.
  • Not Synced
    It's important to note
    that the rebase command
  • Not Synced
    is altering all of the commits
    present in the branch.
  • Not Synced
    It's preserving all of the work you did,
  • Not Synced
    but their location and relationship
    to other commits
  • Not Synced
    is all changing.
  • Not Synced
    This is primarily used for a branch
    that you only own,
  • Not Synced
    and isn't being worked on by others.
  • Not Synced
    The change in the relationship,
  • Not Synced
    and identifier for each of those commits,
  • Not Synced
    makes it difficult to reconcile
    with the work of others.
  • Not Synced
    We're primarily talking about a branch
    that you are focused on.
  • Not Synced
    But with those constraints in place,
    the use is quite simple.
  • Not Synced
    git checkout to the feature branch,
  • Not Synced
    git rebase on the source branch,
    typically master.
  • Not Synced
    That will then iteratively walk through
    all of the commits
  • Not Synced
    that have happened on the feature branch,
  • Not Synced
    and replay them as if they were being
    robotically rewritten,
  • Not Synced
    starting from the latest point in time
    on the master branch.
  • Not Synced
    When the process completes,
  • Not Synced
    after seeing it step through
    all of the individual commits,
  • Not Synced
    it will let you know that
    the rebase is complete,
  • Not Synced
    and you'll return to the command prompt
  • Not Synced
    and what appears to be a similar state
  • Not Synced
    to before you ran that instruction.
  • Not Synced
    However, all of those historical commits
    now have new identifiers,
  • Not Synced
    keep that in mind.
  • Not Synced
    You'll find a request to use this pattern
  • Not Synced
    is most common in open source projects.
  • Not Synced
    It's because they want to optimize
  • Not Synced
    for future readership of the code base.
  • Not Synced
    A single straight line of history
    provides the easiest reading
  • Not Synced
    for a future contributor to this project.
  • Not Synced
    This is why they put the burden
    on the contributors,
  • Not Synced
    to make the history clean.
  • Not Synced
    It's an effort, but one that benefits
  • Not Synced
    every future collaborator on this project.
  • Not Synced
    Continuously delivered applications,
  • Not Synced
    such as web services, and web apps,
  • Not Synced
    are optimized, generally,
    for merges, not rebase.
  • Not Synced
    They want the quickest possible
    delivery mechanism
  • Not Synced
    to send a change, small and focused,
    into the master branch.
  • Not Synced
    If that doesn't do
    everything that it should,
  • Not Synced
    another branch is worked on,
    and merged back in again.
  • Not Synced
    Rebase is a powerful feature
  • Not Synced
    that lets you optimize
    for clarity of history.
  • Not Synced
    Just bear in mind the needs
    of your project and your team.
  • Not Synced
    If it is for quick delivery
    of feature branches,
  • Not Synced
    just merge them in.
  • Not Synced
    If it's for clarity of history,
    engage in using Rebase.
  • Not Synced
    Thanks for watching this
    Git & GitHub Foundations
  • Not Synced
    episode on Rebase.
  • Not Synced
    Be sure to subscribe
    to our channel, over here,
  • Not Synced
    ask us questions or comments
    in the box below,
  • Not Synced
    or watch one of the related episodes,
    such as on creating a branch.
Title:
Rebase • GitHub & Git Foundations
Video Language:
English
Team:
GitHub
Project:
Git and GitHub Foundations
Duration:
04:21
There has been no activity on this language so far.

English subtitles

Revisions Compare revisions