Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excluding Environment Files from Github Angular 4 Project

How do i exclude environment files from github for angular 4 project.

I have updated my .gitignore to the following, but my environment files are still being synchronised to github: /src/environments/**

# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
/tmp
/out-tsc

# dependencies
/node_modules

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
testem.log
/typings
/src/environments/**

# e2e
/e2e/*.js
/e2e/*.map

# System Files
.DS_Store
Thumbs.db
like image 476
ccocker Avatar asked Jul 28 '17 10:07

ccocker


People also ask

How do I ignore certain files in Git?

If you want to ignore a file that you've committed in the past, you'll need to delete the file from your repository and then add a . gitignore rule for it. Using the --cached option with git rm means that the file will be deleted from your repository, but will remain in your working directory as an ignored file.

What is Gitignore file in angular?

gitignore files are created when using the angular ng tool to create an application. You can manually add the file if the application was created manually. The angular project makes use of Typescript. For example, Typescript compiler or transpiler the components into JavaScript during running angular application.

What is exclude file in Git?

In Git, you can exclude a file locally - i.e. only on the current computer. Inside the . git folder for your project, there is a file /info/exclude . This file has the exact same structure as a . gitignore file, so you can add the file patterns for any files which must be excluded locally, inside that file.

What are environment files in angular?

An Angular Application Environment is JSON configuration information that tells the build system which files to change when you use ng build and ng serve . Let's say you have a back end REST API deployed on a server that provides services to your Angular application.


1 Answers

To quote the Git website:

The purpose of gitignore files is to ensure that certain files not tracked by Git remain untracked.

In other words, gitignore won't remove files that are already in your repository, it'll just stop them being added in the first place. So if you've already accidentally commited your environment files, adding them to gitignore isn't enough; you'll also need to untrack the files.

The documentation goes on to say how to fix it:

To stop tracking a file that is currently tracked, use git rm --cached.

Note that this won't remove the file from your commit history, however - if you've accidentally leaked any sensitive info, see the GitHub documentation for info on what to do.

like image 193
Joe Clay Avatar answered Sep 21 '22 17:09

Joe Clay