emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Git question: when using branches, how does git treat working files when


From: Alan Mackenzie
Subject: Git question: when using branches, how does git treat working files when changing branches?
Date: Wed, 28 Oct 2015 19:20:17 +0000
User-agent: Mutt/1.5.23 (2014-03-12)

Hello, Emacs.

I want to start using git branches, so as to be able to work on several
distinct things at the same time.

My question is, how does git handle working files (which haven't been
committed) when changing from one branch to another.  I've spent the
usual two hours searching the fine manuals without turning up a clear
explanation.

One thing that worries me is that the same command "git checkout" is
used to change branches and to revert changes to a file.  So it seems
plausible that each time I swap to a different branch I'm in danger of
irrevocably losing existing changes to source files.

So, what happens to to changes in the working directory when changing
branches?
1. git refuses to change branches because there are uncommitted changes.
2. git changes branches, discarding all uncommitted changes.
3. git changes branches, leaving the changes from the previous branch in
the working directory.

What I really want to happen is
4. git maintains uncommitted changes separately in each branch.

I suspect 4. is not the way git works.  So, how do I best simulate 4.?
I would like to be able to move freely between git branches without
suffering stupid restrictions like having to worry about preserving
changes in the working directory.  Is there some variant of "git stash"
which might do what I want?

TIA!

-- 
Alan Mackenzie (Nuremberg, Germany).



reply via email to

[Prev in Thread] Current Thread [Next in Thread]