Git is a tool that offers a version control system in order to record changes to any type of file, over time, so that it's possible to recall specific versions later.
The following terms are used:
<git-server>
can be bitbucket.org
, github.com
, gitlab.com
or similar;git clone
;git init
.These are the steps to install Git:
git
: sudo apt install git
user.name
and user.email
, which will appear in commits for every repository, with the commands: git config --global user.name "<user>" git config --global user.email "<my@mail.com>"
Configuration settings can be checked with:
git config --list --show-origin
Normally, the username and password are requested at each remote connection. Their input can be avoided or reduced using one of these two methods, inside a Git directory (they will take effect at the next input):
git config credential.helper 'cache --timeout 7200'
git config credential.helper store
Important: now credentials are unencrypted on disk, protected only by filesystem permissions.
Two ways are possible:
In both cases, an empty or an existing Git remote repository must exist.
To start controlling with Git any directory, open a terminal inside it and run:
git init
Then add the link to the remote repository:
git remote add origin https://<git-server>/<user>/<name-repo>.git
Finally, link the local branch master with the remote one:
git push --set-upstream origin master
To start controlling with Git a copy of an existing remote repository <name-repo>
, open a terminal where to save the clone and run:
git clone https://<user>@<git-server>/<user>/<name-repo>.git
A .gitignore
file specifies the directories or the files that Git should ignore.
.gitignore
file within the root directory of a local repository.# ignore these directories and their content <dir> # ignore these files <path>/<file.ext>
Tip: to ignore the content of a directory except for one sub-directory:
!dir/ # do not ignore this directory dir/* # .. but ignore its content !dir/sub-dir/ # .. except this sub-directory