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.