<commit_before>---
layout: post
title: easily fetching upstream changes
category: intermediate
---

This tip comes from "<NAME>":http://blog.davglass.com/, whose work on "YUI":http://developer.yahoo.com/yui/ at "GitHub":http://github.com/yui requires him to bring in commits frequently. So, he's created a "helpful alias":http://gitready.com/intermediate/2009/02/06/helpful-command-aliases.html so he can merge in changes easily. 

First off, he's got a consistent naming scheme for his upstream remote: 

@git add remote upstream git://github.com/user/repo.git@

Just throw this in your @.gitconfig@ and you're all set:

<pre>
[alias]
  pu = !"git fetch origin -v; git fetch upstream -v; git merge upstream/master"
</pre>

Now @git pu@ will grab all of the latest changes from both remotes, and then merge in the commits from upstream. 

How is this different from just doing a @git pull upstream master@? This brings in changes from two different sources: his own fork and the main repository (the upstream). Doing a "pull":http://gitready.com/beginner/2009/01/21/pushing-and-pulling.html usually only brings changes in from one source. If you're confused about how this works, check out the History section of "Git for Computer Scientists":http://eagain.net/articles/git-for-computer-scientists/#history for some graphs on how the fetching and merging process works.

Of course, there's plenty of different ways you could tackle this problem. For example, you could use "rebase":http://gitready.com/intermediate/2009/01/31/intro-to-rebase.html or even "pull with rebase":http://gitready.com/advanced/2009/02/11/pull-with-rebase.html instead of merging. It all depends on how you want to organize your repository's history, and what's easiest for you. 

If you have aliases or suggestions to make this process easier, let us know!

<commit_msg>git remote add, not git add remote<commit_after>---
layout: post
title: easily fetching upstream changes
category: intermediate
---

This tip comes from "<NAME>":http://blog.davglass.com/, whose work on "YUI":http://developer.yahoo.com/yui/ at "GitHub":http://github.com/yui requires him to bring in commits frequently. So, he's created a "helpful alias":http://gitready.com/intermediate/2009/02/06/helpful-command-aliases.html so he can merge in changes easily. 

First off, he's got a consistent naming scheme for his upstream remote: 

@git remote add upstream git://github.com/user/repo.git@

Just throw this in your @.gitconfig@ and you're all set:

<pre>
[alias]
  pu = !"git fetch origin -v; git fetch upstream -v; git merge upstream/master"
</pre>

Now @git pu@ will grab all of the latest changes from both remotes, and then merge in the commits from upstream. 

How is this different from just doing a @git pull upstream master@? This brings in changes from two different sources: his own fork and the main repository (the upstream). Doing a "pull":http://gitready.com/beginner/2009/01/21/pushing-and-pulling.html usually only brings changes in from one source. If you're confused about how this works, check out the History section of "Git for Computer Scientists":http://eagain.net/articles/git-for-computer-scientists/#history for some graphs on how the fetching and merging process works.

Of course, there's plenty of different ways you could tackle this problem. For example, you could use "rebase":http://gitready.com/intermediate/2009/01/31/intro-to-rebase.html or even "pull with rebase":http://gitready.com/advanced/2009/02/11/pull-with-rebase.html instead of merging. It all depends on how you want to organize your repository's history, and what's easiest for you. 

If you have aliases or suggestions to make this process easier, let us know!


{'fraction_non_alphanumeric': 0.09668731483975222, 'fraction_numerical': 0.01723673579315917, 'mean_word_length': 4.390420899854862, 'pattern_counts': {'":': 16, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, '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': '3747475', 'n_tokens_mistral': 1130, 'n_tokens_neox': 1014, 'n_words': 464}