emacs-devel
[Top][All Lists]
Advanced

[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: Óscar Fuentes
Subject: Re: Git question: when using branches, how does git treat working files when changing branches?
Date: Wed, 28 Oct 2015 23:59:03 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Alan Mackenzie <address@hidden> writes:

Joining the emacs-devel git hot line...

>> By default git will complain if changing branches would revert
>> uncommitted changes.
>
> OK, I started with a test repository, with some changes in (which I saved
> in a diff file).  After listing the available branches, and chosing one
> at random, I did
>     $ git checkout /origin/master
> , and got some message or other about a detached head.  Without doing
> anything else I then switched back with
>     $ git checkout master.
>
> git status now reports that the working directory is "clean".  So one of
> these two operations has discarded my changes.

This is hard to believe, so I tried your steps:

address@hidden:~/dev/emacs/emacs$ git checkout /origin/master
fatal: Could not switch to '/origin/': No such file or directory

As you can see, your first command fails to complete. I requested this
on a previous question of yours about git and I request it again: please
post the *exact* commands and its output. Otherwise, claims like what
you made above are dubious, at best.

[snip]

>> 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)
>
> The problem is that, according to David K, there's only one stash stack,
> so it would be very inconvenient having to keep track of which entries in
> this stack belong to which branches.

David Kastrup also suggested to commit your changes before switching
branches, I wonder why you ignored his advice.

Over the years I used several VC systems (CVS and subversion, among
others) and git is, by far, the one that makes things easier when you
don't want to lose your changes, committed or not.

Finally, I wholeheartedly recommend to give Magit a try.

[snip]




reply via email to

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