What files from a MEAN project should I send to GitHub?

5

I created a MEAN project in MVC and I'm trying to put it in GitHub, but I'm not sure what to send. If I try to send the folder all it gives error saying that there are more than 2 thousand files because of the modules of NodeJS, Bower, etc. So what files do I really need to send to GitHub?

    
asked by anonymous 23.09.2017 / 01:18

3 answers

3

NPM and Bower folders do not need to be sent to the repository. This is one of the advantages of using a package manager.

To ignore these files, you need to create a .gitignore file in the project root.

The contents of the file should be something like:

/node_modules/
/bower_components/
    
23.09.2017 / 01:34
3

First, have Git installed and configured on your machine.

As you mentioned, your project has many packages. When using a package manager it is not necessary to send the packages to the repository because of the file containing the list of all packages and dependencies used. In most managers this file is package.json .

To prevent packages from being sent, create a file called .gitignore . The contents of this file will define which folders and files should not be uploaded to version control. This varies from environment to environment and from project to project.

On the Mac, for example, a .DS_Store file is created in all folders, which has some file explorer parameters. This is an example of a file that should not be sent to Git.

Another situation is some text editors or IDEs, such as Visual Studio Code, which creates a .vscode folder with the editor / IDE settings specific to your project. One more that should not be sent.

I'll leave an example of .gitignore as I would in an environment like yours:

/vendor/
/node_modules/
/bower_components/
.DS_Store

With .gitignore created and Git installed you are ready to send your code to GitHub. If you have not yet created a local Git repository, follow the steps below:

Navigate to your project. I do not know if you're using Mac or Windows, but it's simple in both cases. Open the terminal on the Mac or the command prompt in Windows and navigate to the root folder of your project. You can use the cd <caminho> command in this case on both platforms.

Create a local repository. Still using the command line, run git init to create the repository.

Commit what you have. Run git add . to add all files in the folder to your pending commit changes. Finally, run git commit -m "<mensagem qualquer>" to actually "commit" in the local repository.

Ok, local repository created, now for GitHub.

Create a GitHub repository. Click here and create a new repository. Since you already have a .gitignore , create this repository without it.

Add your GitHub repository as a remote. Use the git remote add origin https://github.com/<seu_username>/<nome_repositorio>.git command to set your remote repo .

Push the local changes to the remote. Rotate the command git push -u origin master .

Now just go to https://github.com/<seu_username>/<nome_repositorio> to see if everything is there as it should be.

    
23.09.2017 / 05:20
1

Github has a repository with typical% examples . One of them (link here) is .gitignore for Node.js .

The function of the .gitignore file is exactly not to send epitheme files to the Git, files that are only needed in compilation, and generally all files that are not part of the application code.

For the other files there is .gitignore that indicates dependencies and which files and their versions to install with package.json .

The content of this npm install for Node.js is:

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# ficheiros gerados pelo servidor, temporários
pids
*.pid
*.seed
*.pid.lock

# diretoria da ferramenta jscoverage/JSCover
lib-cov

# diretoria de ferramentas como o istanbul
coverage

# diretoria de respostas de testes de alguns programas
.nyc_output

# ficheiro temporário do Grunt
.grunt

# diretoria da ferramenta Bower
bower_components

# ficheiro de configuração de node-waf
.lock-wscript

# diretoria de ficheiros compilados (isto depende de que nome dás às pastas e se queres ou não ter ficheiros de release no Github)
build/Release

# Dependências
node_modules/
jspm_packages/

# diretoria da ferramenta typescript
typings/

# diretoria da npm opcional
.npm

# diretoria do eslint opcional
.eslintcache

# log/hitoria de REPL
.node_repl_history

# Resultado de comprimir com 'npm pack'
*.tgz

# Verificador de integridade do Yarn
.yarn-integrity

# variáveis do ambiente 
.env
    
23.09.2017 / 08:22