Git is a decentralised version control system. The best there is. Git is a developers tool for version control, backup, and sharing code. It is meant for professional project work and/or assignments in your studies.
Let us assume you must develop a website. In the process files must be backed up, shared between you and your codevelopers, in such a way that it is easy to experiment with the content, and try out ideas out before deciding on the final status. The website files eventually also have to be placed on one of your servers for publication on the web, of course.
All this is done easily with Git.
As a decentralised version control system Git make sure that the totality of the code of a project is available on every project member's computer. But before we get there, some project member, let us call her the initiator, project manager, must create and initialize a project and its repo, short for repository. A repo is really just a fancy name for a directory, aka folder, containing your project subdirectories, and files.
There are two ways she can get started. Locally on her own computer, or remotely, ie on a Git server on the internet.
There are some basic tasks to be executed by the initiator:
Assignment2020a, or
DentistReservationSite rather than
Assignment 2020 a, or The Dentists
Reservation System Website. A good repo name
follows the rules for a good variable name in a program,
one word that says it all.
It goes without saying that the repo for
a web project should be placed somewhere
wisely in the filesystem
of your computer, eg in htdocs,
or www directories.
mkdir projectname cd projectname git init
The first command creates a directory, the next positions an invisible activity pointer in it, and the third creates an empty repository in the directory, your project home. If she checks for repo content she may not see anything. Git's own files are hidden.
README.md,
index.html,
projectname.js,
…
She must then make them known to Git collectively
by this command:
git add .
or individually by this:
git add projectname.js
Whatever is not added is unknown to Git.
git commit -m 'some message relevant to commit'
A commit or checkpoint is a state of your work that you may later make Git return to if some later development does not work out as expected or desired.
At this point she has done the first step in a development cycle. Now if she works alone, she may do some more work, test it, commit it, and repeat that cycle until the project or assignment is finished.
Git knows what she has done, and moreover, Git knows each commit, so that she may undo/redo work with the commits from Git. If she works alone or if she doesn't need to share the work with others, everything is fine.
If the above work has to be shared with someone, other project members in the same project, or just for disseminating her work, she has to look at a Git Server. If she watched the referenced videos, she was introduced to github.com. It is arguably the most well known, but there are others. Yours truly have taken a liking to bitbucket.com, and gitlab.com the former of which will be used in this example. In either case she must register as a user, which for the purposes of this programme is free.
the following three commands
cd projectname git remote add origin https://youruserid@bitbucket.org/youruserid/projectname.git git push -u origin master
The first points to the project directory. Not necessary if you terminal program is already there. The next is a one time command telling Git that the remote friend of this project is whatever the url says. Finally, the third command copies the local master, name of local repo, to origin, name of remote repo, at the server.
The beneficiaries of the sharing, it might be you as a member of the project tema, or yours truly as a teacher for correcting assignments, there are two ways of getting the repo and its content:
cd parentfolder git clone https://youruserid@bitbucket.org/youruserid/projectname.gitThis command will create the folder
projectname already initialized with git and
containing the repo. Ready for work.
git fetch https://youruserid@bitbucket.org/youruserid/projectname.git
In either case you may go directly into the "Do some work" cycle outlined previously.