How to ignore .env file while pushing or pulling from gitlab? [Laravel]
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
- Run this code in terminal in your local project
git rm --cached .env
- The code will ignore
.env
file.
- The code will ignore
git add .
git commit -m “Untracking .env file from local.”
- Now login to gitlab.com and see
.env
file is deleted. - Login to your
cPanel
and openFile manager
. - Open
public_html/
direction of your project - 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?