News for hackers. Stuff that matters.
Re:Git Tips for Beginners Interested in Open Source by richardwhiuk on Monday September 09, 2013 @09:40AM (#6353345)
Trunk is normally called origin in git nomenclature.

git push -f needs a big red box round it, not as a normal thing to do.

If you want to fix a pushed commit, do a new commit! If you keep pushing dodgy commits, try waiting between committing and pushing, or get better at reviewing your changes.

Re:Git Tips for Beginners Interested in Open Source by js2 on Monday September 09, 2013 @02:52PM (#6355383)
Trunk is normally called origin in git nomenclature.

Pedantically, when you refer to "origin", you're referring to the default branch for the remote named "origin" (i.e. the branch referred to by refs/remotes/origin/HEAD after cloning).

This is typically master, but not necessarily. In fact, you can update refs/remotes/origin/HEAD to point to any branch under refs/remotes/origin via "git remote set-head". (It's also possible that the remote repo's HEAD was something other than master when you cloned.)

If you want to be explicit, use origin/master, or refs/remotes/origin/master to be more explicit still.

The same applies for other remotes you may have configured in the same repo.

A related concept is the @{u}/@{upstream} token. Git resolves this token from the currently checked-out branch's configuration. e.g., if master is checked out (i.e. HEAD is refs/heads/master), git checks in .git/config for branch.master.remote and branch.master.merge and uses those to determine the upstream branch. In this example, those would typically be branch.master.remote=origin and branch.master.merge=refs/heads/master, which git resolves to refs/remotes/origin/master.

Finally, @{upstream} can be configured via git branch --set-upstream-to=... (in older versions of git the more confusing and now deprecated --set-upstream was used).

Re:Git Tips for Beginners Interested in Open Source by markberger on Monday September 09, 2013 @09:49AM (#6353399)
Thanks for the comments Richard. Since Github uses origin as user's fork of the project, I was trying to distinguish the project's main repository and the user's fork. Admittedly, after seeing comments from other people, trunk probably isn't the best name for it.
Re:Git Tips for Beginners Interested in Open Source by lambda on Monday September 09, 2013 @11:29AM (#6354031)
My convention is usually to clone from the upstream project, thus it winds up being "origin", and then adding my own repository as another remote, named after my username. If there are any other users whose repositories I'm following, I add theirs as other remotes named after their usernames as well, remaining consistent.

That way, when I pull from origin, I'm pulling from whatever the official origin repository is; when I pull from another named repo, it's named after whose repo it is.

It's also frequently the case that I've cloned from upstream before ever forking the repo on GitHub. It's only once I have any changes I need to make that I create a fork and add my own remote.

Re:Git Tips for Beginners Interested in Open Source by js2 on Monday September 09, 2013 @02:55PM (#6355406)
This is an excellent workflow and then one I use as well.
Re:Git Tips for Beginners Interested in Open Source by steveklabnik on Monday September 09, 2013 @10:35AM (#6353673)
I use 'upstream' for this purpose.
Re:Git Tips for Beginners Interested in Open Source by mataug on Monday September 09, 2013 @10:41AM (#6353716)
Agreed, git push -f has caused a lot of grief because of git newbies. So in my workplace its considered a cardinal sin except under some special circumstances. It needs a really big RED box around it.
Re:Git Tips for Beginners Interested in Open Source by ulisesrmzroche on Monday September 09, 2013 @12:28PM (#6354402)
Special circumstances being the common case of working in your own private branch? Kinda weird to make that big of a deal out of it.
Re:Git Tips for Beginners Interested in Open Source by culp on Monday September 09, 2013 @10:14AM (#6353537)
I've generally considered trunk to be "upstream"