Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
April 20, 2021 08:48 pm GMT

GIT Quick Course

[Clique aqui para ler em portugus]

What is?

Git is a free and open source distributed version control system, designed to handle everything from small to large projects, with speed and efficiency.

What is the advantage?

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.

History

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.

Installation

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.

Setting

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 vim$ git config --global user.name "meunome"$ git config --global user.email "[email protected]"

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.

Hosting

  • 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/

SSH

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)

Adding public key on the server

  • 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 users 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;

Starting Project

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>

Commit

What is it for?

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.

How to make a commit?

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

Creating GitIgnore

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 .gitignore
https://www.toptal.com/developers/gitignore

Commit with emoji

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.

https://github.com/cooperka/emoji-commit-messages
https://www.webfx.com/tools/emoji-cheat-sheet/
https://github.com/dannyfritz/commit-message-emoji

Coding Standard

Some small tips on how to write a commit, but that help to maintain a good history in a project.

Documentation

If you need to read ask questions we have the official website
https://git-scm.com/doc
But if you want something more direct we have git explorer
https://gitexplorer.com/

Quick courses

If you need to have an overview with a practical course you can try the links:
https://learngitbranching.js.org/
http://try.github.io/

Command List

List of commands for GIT.

Thanks for reading!

If you have any questions, complaints or tips, you can leave them here in the comments. I will be happy to answer!

See you!


Original Link: https://dev.to/walternascimentobarroso/git-quick-course-1kbj

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To