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

Re: Question about your git habits

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 23, 2008, 01:42 UTC
Message-ID
<7vk5kw4fep.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<200802221837.37680.chase.venters@clientec.com>
Chase Venters <chase.venters@clientec.com> writes:

[jc: kernel-list removed from CC: as this does not have anything to do with them]

Show 13 quoted lines
> My question is: If you're working on multiple things at once,
> do you tend to clone the entire repository repeatedly into a
> series of separate working directories and do your work there,
> then pull that work (possibly comprising a series of
> "temporary" commits) back into a separate local master
> respository with --squash, either into "master" or into a
> branch containing the new feature?
>
> Or perhaps you create a temporary topical branch for each
> thing you are working on, and commit arbitrary changes then
> checkout another branch when you need to change gears, finally
> --squashing the intermediate commits when a particular piece
> of work is done?

It is a matter of taste, but in any case, you should not have to squash that often. If you find you are always squashing because you work on one thing and then switch to another thing before you are done with the former, something is wrong.

	Clarification: I am not saying squashing is wrong.  I am
	just saying you should not have to.

If you want to park what you were working on before switching to do something else, you can (and probably should) commit and it is a very valid thing to do (an alternative is "git stash").

When resuming, if that parked commit was half-baked and something you do not want to go back to later, then the next commit (be it another commit that merely "parks" before getting distracted to do something else, or a commit that finally gets everything "finito") can be made with "commit --amend". That way, your sequences of commits will consist of only logically separate units, without half-baked ones you had to create only because you switched branches.

Some people prefer to use multiple simultanous work trees. You certainly can use "clone" to achieve this. And local clone is very cheap as it shares the object database from the origin by default.

Many people prefer to use topic branches, and working in a single repository with multiple branches and switching branches without ever cd'ing around is certainly a possible and very valid way to work. As long as your build infrastructure is sane (e.g. your project does not have a central header file that any little subsystem change needs to modify and included by everybody, which tends to screw up make quite badly), switching branches would not incur too much recompilation either and it obviously will save disk space not having to leave multiple checkout around.

You can also work with a single repository, multiple branches and have multiple simultaneous work trees attached to that single repository, by using contrib/workdir/git-new-workdir script.

Previous: Al ViroNext: Samuel Tardieu
Message 8 of 29 in “Question about your git habits”
  1. Chase VentersFeb 23, 2008
  2. Tommy ThornFeb 23, 2008
  3. Steven WalterFeb 23, 2008
  4. Jan EngelhardtFeb 23, 2008
  5. Al ViroFeb 23, 2008
  6. Junio C HamanoFeb 23, 2008
  7. Al ViroFeb 23, 2008
  8. Junio C HamanoFeb 23, 2008
  9. Samuel TardieuFeb 23, 2008
  10. Daniel BarkalowFeb 23, 2008
  11. Jeff GarzikFeb 23, 2008
  12. Mike HommeyFeb 23, 2008
  13. Rene HermanFeb 23, 2008
  14. Willy TarreauFeb 23, 2008
  15. Sam RavnborgFeb 23, 2008
  16. Jakub NarebskiFeb 23, 2008
  17. J.C. PizarroFeb 23, 2008
  18. J.C. PizarroFeb 23, 2008
  19. Charles BaileyFeb 23, 2008
  20. J.C. PizarroFeb 23, 2008
  21. Charles BaileyFeb 23, 2008
  22. J.C. PizarroFeb 23, 2008
  23. Charles BaileyFeb 23, 2008
  24. J.C. PizarroFeb 23, 2008
  25. Charles BaileyFeb 23, 2008
  26. J.C. PizarroFeb 23, 2008
  27. Charles BaileyFeb 23, 2008
  28. J.C. PizarroFeb 23, 2008
  29. Mike HommeyFeb 23, 2008

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.