GIT is a distributed version control system (dvcs).
It is one of three popular free dvcs packages, is the most popular, and is the most difficult to use. For more information see the Wikepedia or the official web site.
Windows versions can be downloaded from
the official site
or, more easily, install chocoletey and type
choco install git.install
from a command prompt.
Ubuntu Linux is often shipped with git already installed. If not, just type:
sudo apt install git
MacOS ships with a version of git pre-installed.
-
clone: the initial download of a project repository is done using the
git clone
command, which will create a copy of the source repository in a new sub-directory at the location where you type theclone
command. All othergit
commands are typed from within that sub-directory. -
branch: make a new name for versions of software in your repository.
-
checkout: switch the text in your working files to a different branch.
-
pull: you get updates of an upstream repository using the
git pull
command. -
add: you must mark any changed files which should be commited to the repository using the
git add
command. You mustadd
a changed file, even though it already exists in the repository. This is not intuitive. -
commit: actually adds the files which you have mentioned in
add
commands to the repository. Commits must always have a comment, so the simplest command isgit commit -m "this is my comment"
. -
push: send all committed changes to the upstream repository.
-
merge: combine work from one branch into another branch.
-
rebase: like merge, only more complicated, but sometimes necessary.
Git documentation is notoriously hard to comprehend. This is partly due to the way git grew up -- you can see a complete account of its checkered history in WikiPedia.
Some of our favorite introductions are Sitaram Chamarty's slideshow, Pieter De Decker's How to Git website, and the traninig materials from Tower.
GitHub is a popular web site used for storing repositories of software
which are maintained using git
. It is free to use for open source
projects. Other free-to-use web sites (such as BitBucket)
also use git
.
Open source projects can be freely downloaded from GitHub using http:
,
but in order to freely send updates to GitHub, or to use scp:
protocol,
you will need to register for a free user account, and upload an ssh private
key to it. Instructions for this are clearly available on the site.
If you use a good Integrated Development Environment (like PyCharm) it will handle the git commands for you.
You will often use Git to provision your minion systems. Read the Salt Git state docs when you are ready to automate the use of Git.
Loading a directory tree from a Git repo can be as simple as:
foo_app:
git.latest:
- name: https://mydomain.tld/apps/foo.git
- target: /var/www/foo