First, have the 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 due to the file containing the list of all packages and dependencies used. In most managers this file is the 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 sent to version control. This varies from environment to environment and from project to project.
On Mac, for example, in all folders a file is created .DS_Store
, that 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 folder .vscode
with the specific editor/IDE settings for your project. One more that shouldn’t be sent.
Let me give you an example of .gitignore
as I would in an environment like yours:
/vendor/
/node_modules/
/bower_components/
.DS_Store
With the .gitignore
created and installed Git you are ready to send your code to Github. If you haven’t created a local Git repository yet, follow the steps below:
Navigate to your project. I don’t know if you’re using Mac or Windows, but it’s simple in both cases. Open the terminal on your Mac or command prompt on Windows and navigate to the root folder of your project. You can use the command cd <caminho>
in this case on both platforms.
Create a local repository. Still using command line, run git init
to create the repository.
Commit to what you have. Execute git add .
to add all the files in the folder to your pending commit changes. Anyway, run git commit -m "<mensagem qualquer>"
effectively "commit" in the local repository.
Okay, local repository created, now for Github.
Create a Github repository. Clicking here and create a new repository. As you already have one .gitignore
, create this repository without it.
Add your Github repository as remote. Use the command git remote add origin https://github.com/<seu_username>/<nome_repositorio>.git
to define your remap remote.
Push local changes to the remote. Turn the command git push -u origin master
.
Now just go up https://github.com/<seu_username>/<nome_repositorio>
to see if everything is there as it should be.