Table of Contents
NOTE: Because master changes so frequently, I will regularly rebase the collections-sprint branch against master to make our final merge process easier. I will send a note out to slack before doing the rebase to avoid any conflicts for PR merging process.
What does that mean for your code?
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.
### 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 |
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.
$ 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.
$ 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.
If after rebasing your local branch you get a message like
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.
# change your-branch-name to your actual branch name git push --force-with-lease origin your-branch-name |
References: