0

I keep track of my dotfiles in a bare repo essentially as described here.

When I want to make changes that will be shared between machines I

  • make the change in whatever local branch corresponds to the machine I'm on;
  • checkout master (where the changes from the local branch are typically still visible with git-status);
  • push from there;,
  • check back in to the local branch, and
  • merge master.

This way I can distinguish between global dotfiles common to all machines and individual ones specific to e.g. a particular computer's window manager, etc.

My issue:

On one specific machine making changes to some files in the local branch and then attempting to checkout master results in

error: Your local changes to the following files would be overwritten by checkout: .bashrc Please, commit your changes or stash them before you can switch branches. Aborting

I'm aware of git-stash and can use it to achieve the functionality I want, but I am puzzled as to why this is happening and would like to understand the matter.

I've encountered the error on only one computer, with v.2.7.4 of git (while the one I'm on, not exhibiting the issue, is running v2.14.4, in case it makes a difference).

Furthermore, it only happens with some files: my .bashrc as shown above, but or instance I can modify scripts in my $HOME/bin folder on the local branch, checkout master without stashing, and still have those changes show with git status. I have not been able to detect a pattern as to which files do this (I think it may have just happened with .bashrc so far, but I'm not sure).

Summary:

checkout master without committing or stashing changes errors out on some machines but not others, with some files and not others.

I would like to understand why.

grobber
  • 1
  • 1
  • Are you sure it's not the case of the files being identical on those machines that don't throw the error? – pishpish Jul 28 '18 at 15:31
  • positive: to test this I purposely modify the file. On the machine(s) where the error does not pop up checking out master goes through fine, but I get a notification that the file *has* been changed: M .bashrc, meaning the file was modified in the local branch. – grobber Jul 28 '18 at 15:39
  • That's how checkout is supposed to work - it will carry on your current working tree and index, _unless conflicts arise_. If the file on master and the (unmodified) local file are the same, there will be no conflicts and your new local changes will be carried on, as you describe. – pishpish Jul 28 '18 at 15:42
  • 1
    Ah, I believe I had misunderstood your question: you meant identical files *before* modification, in the two branches. You are right, this was the issue (checked just now): on the machine that errors master and local have different versions of the file. This doe it then (thanks!) but I'm glad I asked: the other post I was directed to is a trove of info. – grobber Jul 28 '18 at 16:02

0 Answers0