Sync Local/Head with Upstream Repo via git.

Forum rules
Share your brain ;)
User avatar
DebianJoe
Frame Buffer
Posts: 1915
Joined: Mon Jul 01, 2013 5:41 am
Location: emacs.d

Sync Local/Head with Upstream Repo via git.

Unread post by DebianJoe » Wed Nov 06, 2013 5:45 am

Let's say that I have forked someone else's (Dkeg's colors) repo, and since he's made some changes since my last pull request, I want to keep my local synced up to what he's added.

Code: Select all

--> git remote -v
origin	https://github.com/DebianJoe/colors (fetch)
origin	https://github.com/DebianJoe/colors (push)
...but mine is just chilling out as an independent fork so it's only worried about being synced to itself. Well, that's not going to work!
First, I need a remote pointing at Dkeg's repo, so that I can fetch all upstream changes.

Code: Select all

`--> git remote add upstream https://github.com/dkeg/colors
Now, I should have both a remote for "origin" and for "upstream"

Code: Select all

`--> git remote -v
origin	https://github.com/DebianJoe/colors (fetch)
origin	https://github.com/DebianJoe/colors (push)
upstream	https://github.com/dkeg/colors (fetch)
upstream	https://github.com/dkeg/colors (push)
Sweet, but that's only adding the remote pointing at the other repo. In order to get all of the changes that have been made, I should probably perform a merge by getting the upstream (dkeg's) repo and then pushing its changes into my local branch.

Code: Select all

`--> git fetch upstream
remote: Counting objects: 15, done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 13 (delta 3), reused 12 (delta 2)
Unpacking objects: 100% (13/13), done.
From https://github.com/dkeg/colors
 * [new branch]      master     -> upstream/master

`--> git checkout master
Already on 'master'

`--> git merge upstream/master
Updating 024b846..7d7987e
Fast-forward
 canvasedpastel     |  26 ++++++++++++++++++++++++++
 canvasedpastel.png | Bin 0 -> 50728 bytes
 fencetrain         |  26 ++++++++++++++++++++++++++
 fencetrain.png     | Bin 0 -> 50244 bytes
 unsiftedwheat      |  27 +++++++++++++++++++++++++++
 unsiftedwheat.png  | Bin 0 -> 48976 bytes
 6 files changed, 79 insertions(+)
For the sake of being double-safe, I generally do a pull again, but it should just tell you that you're already up to date. Now, I've got all of Dkeg's changes, so that if I put in another pull request, it will coincide with any changes that he's made.
|>>BBQ Roaster, Alpha Branch<< | >> clinky << | >> X11 must die << |
Thanks BASIC

User avatar
rhowaldt
Dog
Posts: 4565
Joined: Wed Oct 17, 2012 9:01 am
Contact:

Re: Sync Local/Head with Upstream Repo via git.

Unread post by rhowaldt » Wed Nov 06, 2013 10:48 am

nice. slowly starting to understand git a bit more.
All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.

User avatar
dkeg
Configurator
Posts: 3782
Joined: Sun Nov 18, 2012 9:23 pm
Location: Mid-Atlantic Grill

Re: Sync Local/Head with Upstream Repo via git.

Unread post by dkeg » Wed Nov 06, 2013 2:43 pm

good tut Joe. Knowing at least the basics of Git will really prove helpful (push, pull, branch, merge, clone, fork).

Work hard; Complain less

Post Reply