Git is a free and open source distributed version control system, designed to handle everything from small to large projects, with speed and efficiency.
Imagine being able to discover changes made to a project, when they were made and who made them? Imagine you can use CTRL + Z in your entire project from the beginning.
Torvalds wanted a distributed system that he could use similarly to BitKeeper (BK), but none of the free systems available met his needs, particularly with regard to performance.
Created in 2005 by Linus Torvalds, development started on April 3, 2005. The project was announced on April 6, and became a self-host on April 7.
more information here.
Go to the git official website page and choose your distribution.
the installation is very easy to do, for windows systems it is just download and next, next and finalize, for linux it is just an
apt install git.
When starting to work with git, the first step is to configure it with your defaults, such as email, editor, username and others.
1 — Configuring via the terminal, to configure your git type the commands below
$ git config --global color.status auto $ git config --global color.branch auto $ git config --global color.diff auto $ git config --global color.ui always $ git config --global core.editor vscode $ git config --global user.name "meunome" $ git config --global user.email "email@example.com"
2 — After the configuration is made, a file called .gitignore will be created and it contains all the settings made, if you need to edit it directly, and you can also back it up so that in future installations it is not necessary to reinstall.
follows my configuration file.
- LOCAL: To use git locally, no extra installation is needed, just use git init and ready local server is already working
- GITHUB: GitHub is a Shared Web Hosting Service for projects that use Git versioning control, it has features of a social network such as feeds, followers, wiki and a graph that shows how developers work on the versions of their repositories. https://github.com/
- Bitbucket: Service similar to Github. https://bitbucket.org/
- Gitlab: Similar to Github. https://about.gitlab.com/
To make the communication between machines and servers, it is best to add an ssh key, thus avoiding the need to enter login and password every time to send a new change, if you use linux you can follow the steps below:
cd ~ // go to home $ sudo apt-get install ssh $ ssh-keygen // file name (enter) // password // re-password $ cat ~/.ssh/id_rsa.pub (send the contents of the file to the owner of the project add you)
- github: to add the key on the github server just access the configuration link and then click on keys https://github.com/settings/keys, now just click on the ‘add new key’ button and paste the content of id_rsa.pub here.
- bitbucket: To add to bitbucket just access your user’s configuration page after the link ssh keys, https://bitbucket.org/account/settings/ssh-keys/, now just click on the ‘add key’ button and paste the contents of id_rsa.pub here
- gitlab: To add the key in gitlab, just enter the profile settings (Profile Settings) then ssh keys option (ssh keys). now just click on the Add SSH key button;
To start a project with git just follow the steps below.
- Creating repository: To create the project locally type git init
$ git init <directory> $ cd <directory>
- Cloning a Repository: To download (clone) a project from some server type git clone
$ git clone <link> $ cd <directoryCreated>
A commit serves as a turning point in the project. Git has tools that make it possible to access the project exactly as it was when each commit was made. This has several advantages, such as providing more security to make modifications to the system (after all, if the change is incorrect, it is possible to revert the commit and return the project code to how it was before the commit was made) or facilitate bug fixing. , as it is possible to execute the project locally in a commit prior to the introduction of a specific bug in the code.
To make a commit, you choose the items you want and then add a message
$ git status // Checks the items you want to send $ git add <file_name> // Add the file $ git commit -m "Commit message title" // Write the commit
When we use git we can define files that we do not want to send to the server, for example log files, third party folders or configuration files, for these cases we can create a file called
.gitignore and add the files or directors that we do not want to send.
in this link we can create the default directories to include in
If you want to make the commit more ‘elegant’ it is possible to add emoji both in the title and in the body of the message, however it is necessary to check if the server is supported.
Some small tips on how to write a commit, but that help to maintain a good history in a project.
List of commands for GIT.
If you have any questions, complaints or tips, you can leave them here in the comments. I will be happy to answer!
😊😊 See you! 😊😊