Version Control with GIT: Simple and objective
Version control systems are software that manages versions of any file. It allows you to know the history of changes, in addition to who changed it, also allows to recover old versions, among other functionalities.
GIT is a version control software that came from the team of Linux kernel developers, and had problems with the software of the time. Today the GIT is one of the main software of the genre, and it has several characteristics, such as support for non-linear development, compatibility with protocols, efficient manipulation of extensive projects among several other characteristics.
Go to https://git-scm.com/downloads and install the version that is compatible with your PC. The installation has no mystery and generally the "next, near, end" already solves. After installation I suggest restarting the computer (if it is windows).
It's nothing more than a storage place. Usually each project has a repository.
These repositories can be stored in specific places, such as GITHUB which is most famous today. However there are others, and if you prefer you can make your own storage location. Here we will use GITLAB because this has the advantage of being able to create private repositories without charging for it and only you or who you wish have access.
To create your repository, simply go to the gitlab website (https://gitlab.com/) and register.
After the registration procedure you access the site with your username and password and you can create your project. To do this simply click on "new project", define a name, and the repository of your project will be created.
First open the Console (Command Prompt) and run the code below. This setting only needs to be done once, and is used to identify "who" is using the repository.
git config --global user.name "SEU NOME DE CADASTRO NO GIT" git config --global user.email "SEU EMAIL DE CADASTRO NO GIT"
A New Project:
If you want to create a new folder on your computer with the project created in git, run:
git clone https://gitlab.com/SEU_USERNAME/SEU_PROJETO.git
Project in progress:
If you have already started project development, run:
cd CAMINHO_ATÉ_A_PASTA_DO_SEU_PROJETO git init git remote add origin https://gitlab.com/SEU_USERNAME/SEU_PROJETO.git
After one of the above actions, it is time to send the information to the repository. To view all changes (inclusion, deletion, or change):
1º - Add the files you want to publish:
- To add a file or folder:
git add NOME_DO_ARQUIVO_OU_PASTA
- To add all files that have been changed / inserted / deleted:
git add -A
2º - Update your local repository:
Each person who uses the repository has their own copy, and before updating the project repository you need to update your own repository by doing the following:
git commit -m "Comentário do envio"
After this command all modifications have been written to your local repository. These 2 steps can be performed as many times as you want until you perform the next step.
3rd - Update repository in GIT:
After the process above, it's time to update the project repository, ie publish everything you did. For this:
And, uh, you posted all the changes.
Development in two locations (or more):
By a chance, I use GIT a lot for the projects I develop on my own. And that many times I have two distinct devices that I develop. I make all the modifications on one computer (PC for example), then I update my local repository of the other computer (NOTEBOOK for example). So I can always develop from the latest version without having to copy and paste, or walk with a PenDrive.
If you also need this, and after you have set up your project folder, you can run the command:
This command allows you to update your local repository from changes in the GIT repository.
Ignoring files or folders:
Sometimes you do not want to send some files to the GIT, after all it does not make sense.
Let's say you have a project that has a "LIB" folder that is libraries and does not modify that your project uses. Or, you have created a public project, and would not like to share your "configuration" file.
For these issues, just create a file called ".gitignore". Within this file place in each line the name of the file that you do NOT want to be sent or versioned. This file can be placed in any folder of the project you want.
Want to know more?