[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: |
Yuri Khan |
Subject: |
Re: Git question: when using branches, how does git treat working files when changing branches? |
Date: |
Thu, 29 Oct 2015 08:25:26 +0600 |
On Thu, Oct 29, 2015 at 5:53 AM, Alan Mackenzie <address@hidden> wrote:
>> David Kastrup also suggested to commit your changes before switching
>> branches, I wonder why you ignored his advice.
>
> It wouldn't work well for me. The word "commit" has a meaning,
> something like "hand over on a permanent basis". When you make a
> "commitment", you are pledging your honour that you will stand behind
> what you have committed. What "commit" _doesn't_ mean is "temporarily
> store because there's nowhere better". Of course there are ways of
> undoing a commit if it was done by mistake. But routinely to commit to
> something with the intention of repudiating it later is an abuse. It is
> the sort of thing politicians do.
In Git, committing is actually *the* easiest solution for the general
problem of tracking uncommitted changes per-branch.
In fact, “git stash” does just that: It creates two new commit objects
(one for the working copy state, the other for the staging area state)
on an unnamed branch starting at your current commit, and records the
hash of the second of those commits in .git/refs/stash and in
.git/logs/refs/stash.
The former file is just a pointer (reference) to the last stash made.
The latter is the list of all existing stashes, typically used in
stack discipline (but “git stash pop” accepts an optional argument
specifying which stash to pop).
A repository browser such as “gitk --all” will show you stashes at the
commits they were made from.
Your solution of making a diff file will also work. It will also be a
non-Git reimplementation of an existing Git feature (stashing), and
will have all its deficiencies (tracking difficulties) and then some
(e.g. an external diff file does not automatically state which commit
it was made from).
- Re: Git question: when using branches, how does git treat working files when changing branches?, (continued)
- 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, 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?, 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 <=
- 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
- Re: Git question: when using branches, how does git treat working files when changing branches?, David Kastrup, 2015/10/29
- On the popularity of git [Was: Git question: when using branches, how does git treat working files when changing branches?], Alan Mackenzie, 2015/10/29
- Re: On the popularity of git [Was: Git question: when using branches, how does git treat working files when changing branches?], David Kastrup, 2015/10/29
- Re: On the popularity of git [Was: Git question: when using branches, how does git treat working files when changing branches?], John Wiegley, 2015/10/29
- Re: On the popularity of git [Was: Git question: when using branches, how does git treat working files when changing branches?], Paul Eggert, 2015/10/30
- Re: On the popularity of git [Was: Git question: when using branches, how does git treat working files when changing branches?], Alan Mackenzie, 2015/10/30
- Re: On the popularity of git [Was: Git question: when using branches, how does git treat working files when changing branches?], David Kastrup, 2015/10/30
- Re: On the popularity of git [Was: Git question: when using branches, how does git treat working files when changing branches?], Eli Zaretskii, 2015/10/30