How to sync a fork

How to sync a fork

2018, Feb 25    

1. Introduction

So, you forked a repo, started working on it (or just forgot it there because you also had other stuff to take care of 😂😂️). The parent fork continued evolving and you ended up at point where you want to also update your fork with the last HEAD of the parent,

2. Use Case

Next month Utrecht Java User Group hosts…one of its co-organizers :bowtie: , Sendil Kumar N, who’s gonna give a talk about JHipster, so, I thought about taking a look at it, before the meetup, in order to educate myself a bit. However, after some time I ended up playing with its Kotlin porting, which is still a WIP (for the ones who are interested in contributing :smiley:

The latter implies that it is often updated, so locally, today I still had this in my HEAD:

first

Whereas, remotely, this was the latest update of the day:

second

So, my fork was behind .

How could I easily update it according to the latest HEAD of the parent?

3. Solution

First, check your local’s remote references:

third

Ok, it only contains my fork, so, I have to also add the parent as an upstream:

$ git remote add upstream https://github.com/jhipster/jhipster-kotlin

Let’s confirm it was added:

fourth

Time for magic!!!

fifth

4. References

5. Closing quote

The more you practice, the easier it becomes.