Day 1: Git, the tool you absolutely need

Git is without a doubt the most useful tool for any developer of any kind. Whether you are working alone or with a team git is indispensable.
With this tool, everyone can work on the same project simultaneously, without being in the same place (which is quite normal these days), and allows you to keep track of your work. You have to respect some rules that we will see now.

Remember this mantra: “PULL-COMMIT-PUSH” you will understand later.

Installing Git

If you are a Windows user just go to the official git website, or click here, download, and install it following the instructions.

Instead, if you are a macOS user I suggest you install Homebrew from your terminal with the following command:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

As soon as it is finished, just run this command in your terminal:

$ brew install git

Git is now installed on your computer and ready to be used.

GitHub, Bitbucket and GitLab

I chose to use GitHub, first of all, you have to register an account.

GitHub homepage

after you have completed your registration and responded to the verification email. You need to create your first repository.

This is a process to which you must pay close attention.
The fields to be filled out are the name of the project, a brief description of the project, the public or private visibility of the project.

Public: anyone can see your repository
Private: only you and people authorized by you can see and access it

Finally, we have “.gitignore. It’s a file that you can insert already when creating the repository, it allows git to exclude some folders and files according to your needs.
In my case, I have included one suitable for Unity, but you can choose according to your needs.

Using Git

wherever you want, just right-click and you can open the git terminal immediately.

If you do it inside a folder, it will open directly on the path of the folder you are working in. If instead, you want to move between directories the commands that you will use more are: ls and cd
ls short for list allows you to see the contents of the directory
cd short for change directory allows you to move between directories.

Open Git Bash directly in the folder you want to work in, and enter this command

git init 

now you’ve initialized your folder as a git repository, and with the next command, you can connect it.

git remote add origin https://github.com/your-name/your-project.git

you can find the address to insert on the page of your project on GitHub

click on Code button and copy the URL

First Commit

git pull origin master

COMMIT

A commit is the insertion of your change into the project. To do this we need to create the commit, as the first thing we need to see the modifications made with the command:

git status

then you have to add the files or folders you want to include in the modification. You can insert one folder or file at a time or all at once with the following commands:

git add <folder/file>
git add .

this should be the result, in green the files that have been added and in red those that still need to be added

result of the command “git add Assets”

The last command you have to give is the one that will create the commit with its message ready to be sent.

git commit -m "your first commit"

always write the message is important for you and your colleagues, always try to be clear and concise.

PUSH

we’re at the end. With this last line, you send your changes to the remote repository.

git push origin master 

Congratulations you have completed your first commit.
Remember when you are working not to wait a whole day to send your changes but to break them down into small parts so that it is easy to move in the project.

It’s really over.
Don’t forget
PULL - COMMIT - PUSH

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store