On Mon, Jul 12, 2010 at 3:45 AM, Daniel Carrera <[email protected]> wrote:
> Hi David, > > I have a few Git questions: > > > # clone and track somebody else's work: > > git branch --track my-copy origin/their-feature > > # when working in the my-copy branch, pushing and pulling will do what > you > > mean > > What you are saying here is that when I am in the branch "my-copy", > pushing and pulling will not go to origin/master but to > origin/their-feature. Yes? > Yes. > Next question: I see "origin" coming up a lot in Git. That's the > repository where I initially cloned from. But how do I specify some > other repository? Let's suppose I have two team members called David > and Chris and I want one branch to track David's work and another to > track Chris' work. How would I do that? Would this work: > > git branch --track david-branch http://david.mertens.com > git branch --track chris-branch http://chris.marshall.net > > Can you do something like that? > I believe you can, though it may take two steps. What I am about to say is untested and may be incorrect. It is a reflection of my current, incomplete knowledge, but I think it's close. Anyway, the command syntax to track the branch named feature123 on *my* (fictitious) server would look like this: git checkout --track david.mertens.com/pdl/feature123 I believe that will work, but I'm not positive. If you want to give it a separate name, you would use this command instead: git checkout -b davids-feature david.mertens.com/pdl/feature123 Then on your machine, my branch will be under the name "davids-feature". The reason I am not sure about any of these is because all the git documentation that I can find recommends that you add remotes (remote servers) in a separate step, so you would first add my repo: git remote add david david.mertens.com/pdl You would then create a new branch based on one of my branches using this: git checkout --track david/feature123 > # push your work to the sourceforge server > > git push origin my-feature > > Next questions: > > 1) Why do you always say "origin"? I see that a lot in Git docs and I > don't understand why it is needed. What is "my-featue" here? ... Oh... > I think I get it. "my-feature" is a branch. Right now you are in some > other branch, but you want to push the branch my-feature to > origin/master. Yes? > Close. The command 'git push origin my-feature' would create a new branch on origin (the server). If you wanted to push your local branch called 'my-feature' to origin's 'master' branch, you would specify <localbranch>:<remotebranch>, like this: git push origin my-feature:master Put a little differently (and likely), if I push a branch called 'feature123' to the sourceforge servers, you could check it out to a branch named 'davids-feature'. If you didn't set up your checkout to track with the branch on the server, you would need to explicitly say which branch it is to push to, or it would create a new branch. At any rate, you would use this: git push origin davids-feature:feature123 > 2) And how would this look if I don't want to push to origin? Can I > make an alias so I can do: > > git push david my-feature > I've already answered this, but feel free to post back a clarifying question if my explanation didn't clear it up for you. > > # pull others' contribution to your work from sourceforge: > > git fetch origin > > # then from my-feature branch: > > git merge origin/my-feature > > And this will merge origin/my-feature to whichever branch I am on > right now. Is that right? Or will it always merge to "my-copy" which > we defined earlier? > I'm pretty sure that git merge branchname will always merge the named branch into the currently checked out branch. To merge the feature123 into the master branch, you would do this: git checkout master git merge feature123 Sorry it took so long for me to get back to you. Thanks for asking all these questions because they've helped me to understand git better for myself, I hope. David -- Sent via my carrier pigeon.
_______________________________________________ Perldl mailing list [email protected] http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
