Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [RFC] git-clone: add --track <headname> support

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:43:04

Carl Worth [off-list ref] writes:
I'd love to get that down to:

	git clone <something with <repo> and <branch>>
	cd <project>
	git pull # as needed

and then adding a subsequent branch to track would be:

	git track <something with <repo> and <branch>>
	git checkout <branch>
	git pull # as needed
I have a different suggestion.  Why not forget about 'git clone'?

After working in a clone of git.git, if you want to use the
project history from another related repository, say Shawn's
fastimport, what would you do?

Yes.  You add it with "git remote add".

	git remote add [options] gfi git://repo.or.cz/git/fastimport.git/

If you are _not_ working off of anybody else's work, how would
you start a repository?

Yes, you just do "git init" in an empty repository.

	git init

And after that, in such a repository, certainly "git remote add"
to add the FIRST remote would work, wouldn't it?

So, how about this two-command sequence instead?

 (0) Have this in $HOME/.gitconfig:

	$ cat >>$HOME/.gitconfig <<\EOF
	[branch]
        	autosetupmerge
	EOF

 (1) Prepare your working area and add the remote you want to
     track, with initial fetch:

        $ git remote add -f origin git://repo.or.cz/alt-git.git/

 (2) If you want to fork off of next, you can:

	$ git checkout -b next origin/next

The result of (2) reads like this:

	$ cat .git/config
        [remote "origin"]
                url = /opt/packrat/playpen/public/in-place/git/git.junio/
                fetch = +refs/heads/*:refs/remotes/origin/*
        [branch "next"]
                remote = origin
                merge = refs/heads/next

The [remote "origin"] section was added with (1), and [branch
"next"] was done with (2).  It means "When I am on 'next', if I
did not give any parameter to 'git pull', I want a fetch from
'origin', and then get their 'next' branch merged.".

So after setting up your 'next' branch with a single command (2),
when you are finished working in your 'next' and are ready to
merge the corresponding 'next' branch of 'origin', you can just
say 'git pull'.  Isn't this what you want?

And I do not think trying to mix up (1) and (2) is a great idea.
Whenever you are interested in yet another person's work, you do
(1).  And whenever you want to fork off of some remote tracking
branch you have already done (1) for, you do (2).  IOW, you can
do more than one (2) for a single remote repository.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help