Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • I will send a note when I am going to rebase.  If you are close on a PR, I can wait for it to be merged.
  • Once the rebase happens, you will need to perform the following on your branch.
    • Run the following commands substituting...
      • YOUR-BRANCH-NAME with the name of your development branch
      • "an identifying message for saving any non-committed changes for your branch" as makes sense for your changes.  The message itself is not important.  I often use a marker like "BEFORE_REBASE", which is something that is easy to spot in the listing of stashes.
      • for `git stash apply`, substitute {0} with the actual index of the stash as shown by `git stash list`
    • (Recommended) BACKUP YOUR WORK
      • Before doing a rebase, I make sure I have a copy of my work.  This is useful if there turns out to be lots of conflicts and I'm having trouble resolving them.  I have a known good state to work from.

        Code Block
        ### I GENERALLY MAKE A BACKUP COPY OF THE ENTIRE hyrax DIRECTORY BEFORE DOING A REBASE ###
        $ git checkout YOUR-BRANCH-NAME
        $ cp -R ../hyrax ../hyrax_BEFORE_REBASE
        


    • (Optional) Undo commits putting all changes in your Working Copy
      • If you have made multiple commits to your branch, you may want to optionally do a soft reset before stashing changes.  A soft reset will remove the commits, and keep the changes from the commits in your Working Copy.  Then when you stash, all your changes will be in the stash.  This can avoid conflicts with the rebase.  When you apply your stash, if there are any conflicts, you will see them at that time.

        NOTE: If your commit messages have meaningful details that you want to keep, use `git log` to get the commit messages and manually copy them into an editor so you can reuse them to make a commit after the rebase process is complete.

        NOTE: In the code below, the number after HEAD~ will be the number of commits you have made on your branch.  In the example below, I have made 2 commits.

        NOTE: The before and after status checks are just for you to evaluate whether the changes you expect are there.

        Code Block
        $ git status
        $ git reset HEAD~2
        $ git status


    • (Required) Perform rebase

      NOTE: The stash list show below may be different from what you see if you have multiple stashes saved.

      NOTE: Stashing is only required if you have uncommitted changes.  You can skip all `git stash` commands if all your changes are committed.

      Code Block
      $ git status
      $ git stash save "an identifying message for saving any non-committed changes for your branch"
      $ git stash list
      stash@{0}: On YOUR-BRANCH-NAME: an identifying message for saving any non-committed changes for your branch
      $ git checkout collections-sprint
      $ git pull --rebase origin collections-sprint
      $ git checkout YOUR-BRANCH-NAME
      $ git rebase collections-sprint
      $ git stash list
      stash@{0}: On YOUR-BRANCH-NAME: an identifying message for saving any non-committed changes for your branch
      $ git stash pop stash@{0}
      $ git status

      The status you see before rebasing and after should be the same.

    • (Optional) After rebasing, if you did a soft reset, you may want to commit those changes using the commit messages you manually saved in an editor.
What to do if your branch has diverged after rebase?


If after rebasing your local branch you get a message like

Code Block
languagenone
Your branch and 'origin/your-branch-name' have diverged,
and have 14 and 2 different commits each, respectively.

You can execute the following command to get them back in sync.

Code Block
languagenone
# change your-branch-name to your actual branch name
git push --force-with-lease origin your-branch-name



References: