git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Workflow question

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 26, 2007, 05:29 UTC
Message-ID
<7vlkau0zah.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<46F9CA2A.7000107@gmail.com>
Russ Brown <pickscrape@gmail.com> writes:
> I'm just wondering at this point why git lets you checkout remote
> tracking branches if it's something you really shouldn't do. Unless it's
> something you want to be able to do in edge cases to fix screwups maybe?
You actually never checkout "remote tracking branches".

You can be in two states, either you are on a branch (meaning, if you create a commit, the new commit will have the current tip commit of that branch as its first parent and will become the new tip commit of that branch), or you aren't on _any_ branch.

The latter state is often affectionately called "detached HEAD" state.

This is primarily useful for sightseeing. Sometimes people would want to check out a commit that is not a tip of any branch. The most typical one is "I want to have a checkout of version 2.6.17", and people call that (loosely) as "checking out a tag". In the same way, you can "checkout a remote tracking branch" (but if you want to be anal in terminology, you never "check out a tag" nor "check out a remote branch"---you are detaching your HEAD at the named commit (which could be the one pointed at by the tag, or the one at the tip of your remote tracking branch).

Detached HEAD state allows you to make further commits and merges. Because git allows you to create a new branch from the current commit (i.e. whatever HEAD points at, be it on any branch or detached) without losing local changes in the index nor the work tree, this is often handy for doing quick fixups and experiments --- you first start on detached HEAD and if it turns out not to be so "quick" fixup, at that point you can create a real branch so that you can continue working on it without losing track.

Show 9 quoted lines
> Thanks for this, it's very useful to read examples of workflows in
> actual use. In fact, I was thinking the other day that it would be good
> to have a site that acts as a directory of many different workflows,
> including descriptions of how they work, how you actually go about
> setting it up and using it day to day (i.e. lists of commands for each
> role/task) and the pros/cons that it provides. I reckon that would help
> newbies out quite a bit (if only for the examples). I've seen a few
> individual examples of workflow but nothing like a comprehensive set of
> them.

"Everyday" might be a good starting point for catalogs of workflows for people playing various roles.

Previous: Russ BrownNext: Jeff King
Message 15 of 17 in “Workflow question”
  1. Russ BrownSep 25, 2007
  2. Andreas EricssonSep 25, 2007
  3. Jeff KingSep 25, 2007
  4. Wincent ColaiutaSep 25, 2007
  5. Jeff KingSep 25, 2007
  6. Wincent ColaiutaSep 25, 2007
  7. Russ BrownSep 25, 2007
  8. Jeff KingSep 25, 2007
  9. Russ BrownSep 25, 2007
  10. Junio C HamanoSep 25, 2007
  11. Russ BrownSep 26, 2007
  12. Jeff KingSep 26, 2007
  13. Karl HasselströmSep 26, 2007
  14. Russ BrownSep 26, 2007
  15. Junio C HamanoSep 26, 2007
  16. Jeff KingSep 26, 2007
  17. Andreas EricssonSep 25, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.