I have my local repo in a state that forbid me to either commit, stash, checkout to another branch or even discard changes. So I'm just stuck.
I will try to describe what steps brought me to this situation, as far as I remember.
Please, take a seat.
A not so long time ago, in another computer far, far away... an other dev normalized crlf in the project according to: https://help.github.com/articles/dealing-with-line-endings
In the while (you know, speed of light...) I made some changes locally, commited, and pulled.
When I pulled Git said:
error: Your local changes to the following files would be overwritten by merge:
wp-config.php
wp-config.php
was earlier removed from the index using git update-index --assume-unchanged wp-config.php
since its a template config file adapted to each local environment.
The base "template" can change. Nothing surprising. Here what I planned:
- reindex
wp-config.php
stash
my own config changespull origin master
stash apply
my config back
Things went wrong at step 3. git pull origin master
still raised the error above, as if the stash was ineffective.
git status
said wp-config.php
had changes not staged for commit. That surprised me a bit after a stash.
Since I stashed my changes I ran git checkout -- wp-config.php
... but without any effect! File was still not staged for commit.
Since I was becoming mad, I created a new branch my-config, added and commited wp-config.php
into it, then switched back to master, deleted wp-config.php
(using git rm
), and merged origin/master... with success!
So now that master was up to date and clean, I planned to restore my own config without the help of Git (editing the file manually).
Since I wanted to know what happened, I switched to my-config branch, and tried here a very simple manipulation:
git stash
git stash apply
And guess what? stash apply
failed saying:
error: Your local changes to the following files would be overwritten by merge:
wordpress/license.txt
wordpress/readme.html
...
(all the files that where modified by the crlf conversion)
And now I'm stuck on my branch (and plan to saw it, Francophones will understand ;)) since:
git stash apply
,commit
andcheckout master
gives the error abovegit stash
produces a stash entry but doesn't change the unstaged states- and
git checkout -- <file>
neither removes the unstaged state
The only thing I can do now is to delete all these files (using the OS rm
) to be able to go back to the master branch.
True story.
I would love to understand what happened on the master branch, then on my-config branch, and what brought me in such situations (I suspect using stash on crlf converted file).
Important notes:
- I run on linux
git core.autocrlf
is oninput
- my
.gitattributes
is the same as the one in "dealing-with-line-endings" article - I'm relatively new to Git (2nd day living with it)
When I did stash
on my-config branch it outputed:
warning: CRLF will be replaced by LF in wordpress/license.txt.
The file will have its original line endings in your working directory.
... (one for each crlf converted file) ...
Saved working directory and index state WIP on my-config: dbf65ad my config -- should not be pushed
HEAD is now at dbf65ad my config -- should not be pushed
(dbf65ad
is the only commit I did on my-config branch)