quinta-feira, 30 de julho de 2020

Untracking a local file on GIT

To untrack files in local repository but keep at origin, as our scenario needed; to keep folder or files in git origin repository but untrack any local changes made in this folder, You can use “git update-index –assume-unchanged”. This will enable new developers to get all the files in the repository when cloning. The application can make all the changes it wants in the specified folder, but locally they won’t be committed an pushed to the origin. The only minor problem with this solution is that you have to do this on every new machine that clones the repo. But something positive that comes out of this is that when you need to update files in the untracked folder you can.

1. Preparing the repo

Make sure you add the folder with all the containing files(that you later want to untrack) to the repo. And then commit and push it to your origin. In this example my folder is named Library.






git add -- .
git commit -a -m 'adding library folder'
git push

2. Add this folder to .gitignore







/library/*





And then commit this update. If you need more information about how to use the .gitignore file you can look at git online documentation.
At this stage the folder library and its contents are still tracked by git. Any changes to a file in this folder will therefor be marked as changed still. Lets take care of that next.

3. Untrack files in local repository but keep at origin

Now run the following command to untrack the library folder and its contents:






git update-index --assume-unchanged library/*

Make a change to a file in this folder and git will assume it has not been changed, so you won’t commit anything in this folder.

4. Undo this change

Say you need to update a file in the library folder after a while. Then you need only one command to start track this folder again:






git update-index --no-assume-unchanged library/*

5. Make alias of these commands

If you like you can create aliases for these commands to something simpler:






git config --global alias.assume-unchanged 'update-index --assume-unchanged'
git config --global alias.assume-changed 'update-index --no-assume-unchanged'

This makes you able to run:






git assume-unchanged library/*

and:






git assume-changed library/*

domingo, 26 de julho de 2020

Como arrumar LARAVEL erro 500 - Olhando os arquivos de LOG

É comum tentar acessar o site feito em LARAVEL e retornar com ERRO 500 sem nenhuma informação se é erro de configuração, do servidor, de permissão de arquivos...

A forma mais certeira de consertar o erro 500 é descobrir o que está causando. Para isso basta olhar nos arquivos de LOGs que podem estar espalhados em vários locais.


  • Primeiro procure pelo arquivo "log_error" dentro da pasta "public"
  • Outra opção é procurar pelo mesmo arquivo "log_error" da pasta raiz do LARAVEL
  • Está dificil! Sendo assim tem mais um arquivo de log dentro da pasta /storage/logs
  • Por fim, parece não ser um erro do LARAVEL e sim do servidor... (permissão de arquivos, ou versão errada do PHP, ou outro)... Então, vá no CPANEL e olhe o log do PHP.

chmod recursivo para arquivos e diretórios em servidor http

Muitas vezes ao fazer o upload de arquivos e diretórios para servidores, as permissões de acesso são modificadas e fazem com que retornem erro, por por exemplo em servidor HTTP retorne erro 500.

Normalmente os arquivos são configurados com permissão 644 e diretórios com permissão 755.

Uma forma fácil de atualizar tudo e de forma recursiva é acessar o servidor por SSH e executar os seguintes comandos (executar o comando um nível abaixo do diretorio "meusite"):

find meusite/ -type d -exec chmod 755 {} \;
find meusite/ -type f -exec chmod 644 {} \;