2022-11-20 21:17:25 +01:00
|
|
|
---
|
|
|
|
title: Keep up-to-date on forked repositories
|
|
|
|
categories: [computerstuff]
|
2023-04-10 09:54:18 +02:00
|
|
|
tags: [git]
|
2022-11-20 21:17:25 +01:00
|
|
|
date: 2020-11-14T23:20:16+01:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
I usually fetch the upstream repository and merge it into my local repository,
|
|
|
|
then upload all the merges into the github repository. That works sometimes,
|
|
|
|
but it also fails sometimes with me having an extra commit with merges leaving
|
|
|
|
the git history different from the upstream...
|
|
|
|
|
|
|
|
<!--more-->
|
|
|
|
|
|
|
|
This snippet has been taken from [github.community][1].
|
|
|
|
|
|
|
|
[1]: https://github.community/t/update-a-forked-repository-when-the-original-repository-is-updated/1855/3
|
|
|
|
|
|
|
|
```console
|
|
|
|
$ git checkout master # Make sure you always run the following commands from the master branch
|
|
|
|
$ git fetch --all
|
|
|
|
$ git pull --rebase upstream master
|
|
|
|
$ git push origin master
|
|
|
|
```
|
|
|
|
|
|
|
|
> This will rebase the upstream changes on your local forked version so the
|
|
|
|
> master branch git history will look exactly the same at the end.
|