<commit_before><commit_msg>Adds blog post<commit_after>---
layout: post
title: Quick Tip - Syncing Your Local Git Fork
published: true
---

Having just wrestled for too long with how to sync my local branch - I thought I'd write a quick post on how I got it down.

Setup: I forked a project two days ago and have since been working on my fork locally. In the meanwhile, the original repository I forked had changes made. Before I continued with development, I wanted to make sure that my local branch and the original repository were in sync.

I thought this might be as simple as a *git fetch upstream* (https://help.github.com/articles/syncing-a-fork/) - but it turns out I did not have my *upstream* set. Upon doing a *git upstream*, I received the frustrating message:

*fatal: 'upstream' does not appear to be a git repository*

Indeed, doing a `git remote -v` confirmed this:

*origin https://github.com/my-project/repo-name.git (fetch)
origin  https://github.com/my-project/repo-name.git (push)*

After reading a bit, I attempted a *git remote set-url upstream https://github.com/original-project/repo-name.git*

This, however resulted in *fatal: No such remote 'upstream'*

More reading revealed the answer: I needed to *add* the upstream repository before *fetch*ing from it:

*git remote add upstream https://github.com/original-project/repo-name.git*

Doing a *git remote -v* confirmed I had it set correctly this time:

*origin	https://github.com/my-project/repo-name.git (fetch)
origin	https://github.com/my-project/repo-name.git (push)
upstream	https://github.com/original-project/repo-name.git (fetch)
upstream	https://github.com/original-project/repo-name.git (push)*

Happy coding!
{'fraction_non_alphanumeric': 0.0989399293286219, 'fraction_numerical': 0.0, 'mean_word_length': 4.227692307692307, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 9, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7380717', 'n_tokens_mistral': 500, 'n_tokens_neox': 484, 'n_words': 217}