How to ignore .env file while pushing or pulling from gitlab? [Laravel]

1+

You can simply ignore files in Laravel by mentioning file name(.env) in .gitignore file. But why you are not able to ignore .env? Curious? Well, I was too not able to ignore .env file while either pushing to gitlab or while pulling a fresh project by using clone command. After working for a while, I found one solution. Hope this one helps you too.

Here are the steps

  1. Run this code in terminal in your local project git rm --cached .env
    • The code will ignore .env file.
  2. git add .
  3. git commit -m “Untracking .env file from local.”
  4. Now login to gitlab.com and see .env file is deleted.
  5. Login to your cPanel and open File manager.
  6. Open public_html/ direction of your project
  7. Create .env file and save all your configuration as required.

Now once you push code to master, local .env file won’t get affected. To change .env file for live version, just open cPanel/File manager/public_html/ and configure .env file as per your requirement.

Here is a link if you want to integrate pipeline.

That’s all guys. Now you are good to go.

Well, thank you guys for readying my blog. Hope this is helpful to you. If so, don’t forget to share it.

👍Happy coding👍

1+

Leave a Reply

santoshm