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

Re: question concerning branches

From
Jakub Narebski <jnareb@gmail.com>
Date
Aug 19, 2009, 19:08 UTC
Message-ID
<m33a7noc3u.fsf@localhost.localdomain>
In-Reply-To
<4a8c4425@wupperonline.de>
ib@wupperonline.de (Ingo Brueckl) writes:
Show 8 quoted lines
> Avery Pennarun <apenwarr@gmail.com> writes:
> 
> > You seem to have forgotten the "git commit" step before switching back
> > to master.
> 
> No, I passed over the commit in my example. I know that after the commit the
> things are as they ought to be, but what if I can't do a commit because I am
> in the middle of coding and have to have a break?
Then you use git-stash.  It was invented for that.
 
Show 8 quoted lines
> > You have a modified file in your repository; what did you *want* to happen
> > when you switched branches?
> 
> I want an unchanged file in master if I switch there (because I worked in a
> different branch) and a changed version in the test branch.
> 
> Why is the *master* different depending on whether my work in test in still
> going on or committed?!

Branches are about commits. State of a working directory doesn't belong to a branch (in Git). Learning concepts behind Git would help you in understanding it (Git is very consistent), which in turn would help in using it.

What about untracked files? Do you want to lose them when you switch branches?

Show 7 quoted lines
> 
> Actually, I cannot image how branches are practicable if I always have to
> have in mind possibly still uncommitted work. Shouldn't it be git's work
> to ensure that master will remain it was when branching?
> 
> Without git I'd make a copy for testing new features. With git, it seems that
> I have to do the same (a clone). This is what I don't understand.
You finish old work (or stash it away), _then_ you begin new work.
> 
> > (Many people find the current behaviour very convenient.)

Take the following example. You started coding some feature on 'master' branch, then you realized that this feature is more complicated than you thought at first, so it should be developed in separate topic branch. You do "git checkout -b featureA", and voila you are now coding on feature branch 'featureA'.

> > You might also want to look at the "git stash" command.
> 
> Yes, but isn't it annoying to leave the test branch always either with stash
> or commit in order to have an unchanged master?!
No, it isn't.
-- 
Jakub Narebski

Git User's Survey 2009: http://tinyurl.com/GitSurvey2009
Previous: Ingo BruecklNext: Ingo Brueckl
Message 5 of 21 in “question concerning branches”
  1. Ingo BruecklAug 19, 2009
  2. Bruce StephensAug 19, 2009
  3. Avery PennarunAug 19, 2009
  4. Ingo BruecklAug 19, 2009
  5. Jakub NarebskiAug 19, 2009
  6. Ingo BruecklAug 19, 2009
  7. Avery PennarunAug 19, 2009
  8. Matthieu MoyAug 20, 2009
  9. Jacob HelwigAug 19, 2009
  10. Jakub NarebskiAug 19, 2009
  11. Theodore TsoAug 19, 2009
  12. Jakub NarebskiAug 19, 2009
  13. Theodore TsoAug 20, 2009
  14. Linus TorvaldsAug 19, 2009
  15. Randal L. SchwartzAug 20, 2009
  16. Ingo BruecklAug 20, 2009
  17. Johannes SixtAug 20, 2009
  18. Jakub NarebskiAug 20, 2009
  19. Junio C HamanoAug 19, 2009
  20. Ingo BruecklAug 19, 2009
  21. Andreas EricssonAug 20, 2009

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.