adonthell-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Adonthell-general] Re: Re: [maybe slightly OT] Git pull origin master


From: Chris Frey
Subject: [Adonthell-general] Re: Re: [maybe slightly OT] Git pull origin master
Date: Fri, 17 Dec 2010 03:45:41 -0500
User-agent: Mutt/1.4.2.2i

On Fri, Dec 17, 2010 at 01:39:46PM +0530, shirish ??????????????? wrote:
> Ok, I have to get around this, I have some idea of what you are trying
> to say, the problem is 'origin' and 'master' for me mean the same.

Let's correct this first, since the rest should fall into place
when you understand this.

In git, there is one repository, with all the blobs, trees, and commits
stored under the .git subdirectory.  *Every* piece of data is stored
here.  Even if you have multiple remotes (see below).

When you first do a git clone, it copies the blobs to the local repo,
and you have a full copy of everything.  Git also records that the
remote repo has a branch named "master", and Git keeps track of
where you last saw that branch.

Now, to keep track of all the remote repos that your copy knows
about, Git calls them "remotes".  The default remote that Git
creates for you when you do a git clone is called "origin."

You can think of remotes as directories of remote branches.  Try:

        git branch

This shows all your branches that you are currently working on.  Now try:

        git branch -a

This shows all your branches as well as the branches that Git saw
on the remote server.  It may look something like this (using my
project for now):

        [cdfrey barry-git1]$ git branch -a
        * master
          pristine-tar
          scripts
          remotes/origin/HEAD -> origin/master
          remotes/origin/master
          remotes/origin/mob
          remotes/origin/pristine-tar
          remotes/origin/scripts

So "origin" is just the name for the URL where you got it from,
and that remote server may have multiple branches.

Each time you do a "git fetch origin", Git updates only the branches
in the remote.  So "origin/master" will be updated, but not your own
master branch.  When you do a merge (or a pull, which is a shortcut to
both fetch and merge), it takes the changes seen in "origin/master" and
merges them into your local branch "master."  You can see the differences
between your local branch and the new remote, before you merge, with:

        # see the total diff
        git diff master origin/master

        # see just the commits in the new branch
        git log master..origin/master

        # see commits and the patches for each commit
        git log -p master..origin/master

Both "master" and "origin/master" are individual branch names.
One is your local branch, the other is the branch that Git last
saw on the remote server.  And the remote is called "origin."
You work on the local branches.  The remote branches are for tracking
purposes, but you can still diff against them and create new branches
off them.  (You can manually create a branch at any SHA1 sum commit,
actually).

Note that you can have multiple remotes.  If I was hacking on adonthell,
and Kai was too, and we had different servers we pushed to, you could
track both our repositories, by adding a remote for each.  Then
you could cherry pick the changes you liked best into your own branch.
When you were happy with the result, you could create a remote of your
own, and push *your* branch to that new remote server.  Your Git
repo would have 3 remotes listed, one for each of us, and you would
fetch ours, and push to yours, and merge/cherry-pick/etc between them all.

HEAD is just a shortcut to the currently checked out commit.  I don't use it
explicitly very much.



> Ok, again this one I have to get my head around. Some things I tried :-
> 
> /usr/local/src/adonthell$ git remote show adonthell
> fatal: 'adonthell' does not appear to be a git repository
> fatal: The remote end hung up unexpectedly

Use "git remote" alone to list your remote names.


> /usr/local/src/adonthell$ git remote show origin
> * remote origin
>   Fetch URL: git://github.com/ksterker/adonthell.git
>   Push  URL: git://github.com/ksterker/adonthell.git
>   HEAD branch: master
>   Remote branches:
>     audio_manager tracked
>     logger        tracked
>     master        tracked
>     unit-tests    tracked
>     valgrind      tracked
>   Local branch configured for 'git pull':
>     master merges with remote master
>   Local ref configured for 'git push':
>     master pushes to master (up to date)

You see that "origin" is mostly a shortcut for typing the github url.


> Ok, have to get a 'Git for dummies' book sometime. From what little I
> know, just like in GNU/Linux everything is a file, in Git everything
> is an 'object' right ?

Right.  Everything is a blob.  Some blobs are more special than others,
but they have the same format and the same SHA1 checksum scheme.


> Thanks a lot. It did clear lot of issues for me . Thank you for taking
> time to reply .  I hope this is also helpful to some newcomer
> developer as well to clear confusion.

You're welcome.  I'm a git fan, so answering questions like this is almost
like a hobby. :-)

If you're interested, here's a local talk I gave on git, with notes:

   http://foursquare.net/cdfrey/blog/archive/2010/07/Video__Intro_to_Git.html

- Chris




reply via email to

[Prev in Thread] Current Thread [Next in Thread]