# Git: Sync fork with upstream changes

A forked repository can be synced with the upstream one as follows:

1. Clone the forked repository locally if not already done.
    

```bash
git clone https://github.com/OWNER/FORKED-REPOSITORY.git
```

2. List the remote repository configured for your fork:
    

```bash
git remote -v
```

3. Add a new remote upstream repository that will be synced with the local fork:
    

```bash
git remote add upstream https://github.com/OWNER/REPOSITORY.git
```

4. Verify the configured remote repository for your fork:
    

```bash
git remote -v
```

5. Pull the latest changes from upstream remote:
    

```bash
git fetch upstream
```

6. Checkout to your local master branch of the forked repository:
    

```bash
git checkout master
```

7. Merge upstream/master to local master branch:
    

```bash
git merge upstream/master
```

8. Commit and push your changes to remote fork:
    

```bash
git commit -m 'merged with upstream changes'
git push
```
