Upload .gitignore
Browse filesTo exclude your .env file from being tracked by Git, follow these steps:
Create a .gitignore file in the root directory of your project (if it doesn’t already exist).
Add .env on its line in the .gitignore file.
If you’ve already added the .env file to your repository, you must clear Git’s cache. You can do this by running the following command:
**git rm --cached .env**
Commit your changes and push them to your repository.
By doing this, Git will ignore the .env file, preventing it from being uploaded to GitHub or any other remote repository1. Keep in mind that the .env file often contains sensitive information like API keys and database credentials, so excluding it from version control is essential for security reasons. If you’ve already pushed the .env file to GitHub, make sure to change any keys that were in that file to maintain security
- .gitignore +1 -0
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
git rm --cached .env
|