3
I’m trying to branch out but the git is aborting the operation.
I’m in the branch dev trying to get to the branch master :
$ git checkout master
Error:
error: Your local changes to the following files would be overwritten by checkout:
.env
Please, commit your changes or stash them before you can switch branches.
Aborting
But when I check my work area I find nothing $ git status
:
No ramo dev
Your branch is up-to-date with 'dev/master'.
nada a submeter, diretório de trabalho vazio
As I also try to make a $ git stash
:
No local changes to save
I tried to use the git checkout -f master
but it didn’t work:
error: Entry '.env' not uptodate. Cannot merge.
Observing: Initially the file .env was in the .gitignore, only in order to send to a remote repository I had to remove it. So I did the git push
I was in the .gitignore again added and made a git update-index --assume-unchanged .env
to remove it from versioning.
I think I could use the
git checkout -f master
. But I don’t know if it’s ideal.– augustoppimenta
Can you recover the state of this file according to git? git checkout. env If you can, commit it, and then try to change branch. If not, create a dummy file with the same name '.env' commit and try.
– rafaels88
Hello @rafaels88, how do I recover? And pq/oq makes this command
git checkout .env
?– augustoppimenta
git checkout . env will recover the state of this file relative to the branch you are on. If you want to go back to the state of a file, that is, get it in the way it is pushed, just check out the file. The point is that GIT must have lost the reference to this file. Maybe you removed it with the 'rm' command, you should have done it with 'git rm''.
– rafaels88
I think I got it @rafaels88. I was working on master branch, passed to the dev branch, made some commits, one of them was accessing my .gitignore and remove the line from the .env,dai dei um
$git push dev dev:master
. After that I went back to mine .gitignore added again the .env, Then I removed him from versioning with the commandgit update-index --assume-unchanged .env
and end. Now I just want to go back to the master branch with$git checkout master
to make agit rebase dev
without the file .env be versioned and committed. ?– augustoppimenta
I do, but I think you should go back to . env first, so GIT stops giving this error. Commit that file, shove it, and Git will stop complaining. After that, you give a git rm in that file.
– rafaels88
Showw. I did what you said and it worked.Brigadão @rafaels88!
– augustoppimenta
Let us continue this Discussion in chat.
– augustoppimenta
Good, man! You’re welcome!
– rafaels88