[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Git question: when using branches, how does git treat working files
From: |
Alex Bennée |
Subject: |
Re: Git question: when using branches, how does git treat working files when changing branches? |
Date: |
Wed, 28 Oct 2015 20:10:14 +0000 |
User-agent: |
mu4e 0.9.15; emacs 24.5.50.4 |
Alan Mackenzie <address@hidden> writes:
> 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.
By default git will complain if changing branches would revert
uncommitted changes.
> 2. git changes branches, discarding all uncommitted changes.
You can force it to reset everything (which you don't want)
> 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?
Well I usually do a stash/rebase/stash-pop cycle in magit. However you
may want to look at the rebase.autostash option (since Git 2.6)
>
> TIA!
--
Alex Bennée
- Git question: when using branches, how does git treat working files when changing branches?, Alan Mackenzie, 2015/10/28
- Re: Git question: when using branches, how does git treat working files when changing branches?, Steinar Bang, 2015/10/28
- Re: Git question: when using branches, how does git treat working files when changing branches?, Ricardo Wurmus, 2015/10/28
- Re: Git question: when using branches, how does git treat working files when changing branches?,
Alex Bennée <=
- Re: Git question: when using branches, how does git treat working files when changing branches?, Alan Mackenzie, 2015/10/28
- Re: Git question: when using branches, how does git treat working files when changing branches?, Xue Fuqiao, 2015/10/28
- Re: Git question: when using branches, how does git treat working files when changing branches?, Óscar Fuentes, 2015/10/28
- Re: Git question: when using branches, how does git treat working files when changing branches?, Alan Mackenzie, 2015/10/28
- Re: Git question: when using branches, how does git treat working files when changing branches?, Dmitry Gutov, 2015/10/28
- Re: Git question: when using branches, how does git treat working files when changing branches?, Michael Heerdegen, 2015/10/28
- Re: Git question: when using branches, how does git treat working files when changing branches?, Michael Heerdegen, 2015/10/28
- Re: Git question: when using branches, how does git treat working files when changing branches?, Yuri Khan, 2015/10/28
- Re: Git question: when using branches, how does git treat working files when changing branches?, David Kastrup, 2015/10/29
- Re: Git question: when using branches, how does git treat working files when changing branches?, Alan Mackenzie, 2015/10/29