Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 6 Apr 2017 00:21:13 +0200
From:      Per Hedeland <per@hedeland.org>
To:        freebsd-x11@freebsd.org
Subject:   Re: Switching branches of freebsd-base-graphics with git
Message-ID:  <2f3febf3-fa2f-47d5-58d4-741d5cdc1729@hedeland.org>
In-Reply-To: <CAGhTqAW7aRiFtiM9XrcXVehdoxEMkckLCu651XM9oP7OTRZ1BA@mail.gmail.com>
References:  <E7.99.29375.6FD94E85@dnvrco-omsmta02> <CAPS9%2BSvcSdcALYgRyhdw2oqE93cPUb94pzYsP=BDQQadLXfzmg@mail.gmail.com> <CAGhTqAW7aRiFtiM9XrcXVehdoxEMkckLCu651XM9oP7OTRZ1BA@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2017-04-05 18:19, Doug Kirk wrote:
> `git pull` is just sugar for `git fetch` (fetch remote updates) then `git
> merge` (merge them into the current work tree).
> 
> Since git pulls down the entire repo (unlike svn), `git checkout $branch`
> is enough (AS LONG AS you originally cloned the entire repo instead of just
> one branch -- `-b $branch` on the clone command).

Well, I'm also far from a git expert, even though I've been struggling
with it at $WORK for the last year or so.:-) But AFAIK, though there are
ways to "limit" a clone, '-b <branch>' isn't one of them - it should be
equivalent to doing a clone without -b followed by 'git checkout <branch>'.

But I do think clone vs checkout (and of course git vs svn) is at the
root of Thomas' problem, with the mistaken assumption that 'git checkout
$REMOTE_REPO' will give you a local working tree just like 'svn checkout
$REMOTE_REPO' does (I *still* make that mistake every now and then).

So, as Doug writes, you need to 'git clone' *first*. And this summary of
its commandline is all I've ever needed:

  git clone [-b <branch>] [<directory>]

And with [-b <branch>] taken care of, I believe [<directory>] is the
important thing regarding Thomas' subsequent problem. The man page
(yeah, it has man pages!) says:

    <directory>
        The name of a new directory to clone into. The "humanish" part of
        the source repository is used if no directory is explicitly given
        (repo for /path/to/repo.git and foo for host.xz:foo/.git). Cloning
        into an existing directory is only allowed if the directory is
        empty.

Thus 'git clone https://github.com/FreeBSDDesktop/freebsd-base-graphics.git',
with or without -b, but without <directory>, will clone into
$CWD/freebsd-base-graphics. If you want to clone into
/freebsd-base-graphics, you need to give that path as the last argument
- or, in this particular case, make sure $CWD is the root directory -
but it needs to be non-existing or empty. (Personally I always use the
<directory> argument, to make sure the clone ends up where I want it.:-)

With that done, you should be able to cd into the local clone
a.k.a. wotking tree and 'git checkout' (~= 'svn switch' AFAIK) and 'git
pull' (~= 'svn update') to your heart's content.:-)

--Per Hedeland

> So after the checkout as above, `git pull` should be enough to get the
> currently checked-out branch's updates from the remote repo.
> 
> Even if you didn't clone the entire repo, `git checkout $branch` followed
> by `git pull` is enough to checkout the branch and get its updates.
> 
> You can get a (local & remote) branch list with `git branch -a`. It'll show
> a star for the current branch.
> 
> Also keep in mind that git won't do anything with non-tracked files, so
> you'll likely want to `make clean` to get rid of prior-branch remnants.
> 
> Cheers!
> 
> On Wed, Apr 5, 2017 at 4:06 AM Andreas Nilsson <andrnils@gmail.com> wrote:
> 
>> On Wed, Apr 5, 2017 at 9:33 AM, Thomas Mueller <mueller6722@twc.com>
>> wrote:
>>
>>> I tried to switch freebsd-base-graphics tree from drm-3.8 (something like
>>> that, now outdated to drm-next and made a mess.
>>>
>>> First, from /freebsd-base-graphics, I did
>>> git checkout drm-next
>>> but then git pull didn't work, I got message about not having repository.
>>>
>>> "git checkout drm-next"  switched branches but didn't download anything,
>>> hence my try with "git pull".
>>>
>>> After some struggle, I did
>>> git clone https://github.com/FreeBSDDesktop/freebsd-base-graphics.git -b
>>> drm-next
>>>
>>> from /freebsd-base-graphics directory, but that resuted in the tree being
>>> downloaded to /freebsd-base-graphics/freebsd-base-graphics
>>>
>>> I recovered by renaming (mv) /freebsd-base-graphics to
>>> /freebsd-base-graphics-old, then moved
>> /freebsd-base-graphics-old/freebsd-base-graphics
>>> to /
>>> and then, with the new stuff separated from the old,
>>> rm -R /freebsd-base-graphics-old
>>>
>>> That seemed to work, inelegantly.
>>>
>>> Question is how to switch the branch and download the new branch over the
>>> old, like "svn sw", but with git.
>>>
>>> I looked through the documentation, even went to git-scm.org, even a PDF
>>> book "Jump-Start Git" but still couldn't see what I should have done.
>>>
>>> There has to be a simpler way, but I couldn't find it in the
>> documentation
>>> of git.
>>>
>>> Tom
>>>
>>> _______________________________________________
>>> freebsd-x11@freebsd.org mailing list
>>> https://lists.freebsd.org/mailman/listinfo/freebsd-x11
>>> To unsubscribe, send any mail to "freebsd-x11-unsubscribe@freebsd.org"
>>>
>>
>>
>> Hello!
>>
>> I've switched branches a few time to keep track of progress and going from
>> 11-STABLE to 12-CURRENT. I did
>>
>> git fetch ( this fetch info on new branches and code and so on )
>> git checkout $branch
>> git pull
>>
>>
>> Subsequent upgrades are done with
>>
>> git fetch
>> git pull
>>
>> I'm by no means a git expert, so please correct me if I'm wrong.
>>
>> Best reagards
>> Andreas
>> _______________________________________________
>> freebsd-x11@freebsd.org mailing list
>> https://lists.freebsd.org/mailman/listinfo/freebsd-x11
>> To unsubscribe, send any mail to "freebsd-x11-unsubscribe@freebsd.org"
>>
> _______________________________________________
> freebsd-x11@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-x11
> To unsubscribe, send any mail to "freebsd-x11-unsubscribe@freebsd.org"
> 




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2f3febf3-fa2f-47d5-58d4-741d5cdc1729>