Skip to content

Commit f46b0c5

Browse files
Add in instructions for updating a local branch that was rebased on the remote.
1 parent 3c18dd5 commit f46b0c5

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

episodes/08-rebase.md

+39
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,45 @@ if there are commits on the remote branch
512512
you would override by pushing if you forgot
513513
to check yourself.
514514

515+
## Pulling a Rebased Branch
516+
517+
If you have rebased a feature branch
518+
and then overwritten the remote branch
519+
on GitHub your collaborators may need to pull
520+
these changes to their local copies.
521+
522+
If the collaborator already had a copy
523+
of your branch from before the rebase;
524+
attempting a normal pull will result in a
525+
lot of conflicts due to the incompatible
526+
histories of the original and the rebased
527+
branches.
528+
529+
The collaborator should
530+
first switch to the local branch they want to
531+
overwrite with the rebased remote version:
532+
533+
```bash
534+
$ git switch add_plot_script
535+
```
536+
537+
Now fetch but don't attempt to merge the
538+
remote branch:
539+
540+
```bash
541+
$ git fetch origin add_plot_script
542+
```
543+
544+
Reset the local branch to match the remote origin:
545+
546+
```bash
547+
$ git reset --hard origin/add_plot_script
548+
```
549+
550+
Now their local branch matches the rebased
551+
feature branch from GitHub and
552+
everyone's branches are in sync.
553+
515554
::::::::::::::::::::::::::::::::::::::: challenge
516555

517556
## Modifying Commit Messages

0 commit comments

Comments
 (0)