Tutorials used as reference:
Colt Steele - Youtube video
Colt Steele - Website
Setup Git
First, we have to define and go to the folder where we want to work with our project(s). So for example, I want on my Documents, a folder called "website" because I plan on doing a little HTML website.
cd documents/
I create a folder called "website"
mkdir website
I go into that folder to start:
cd website/
So the path I'm is this one on the terminal:
username@hostname:~/documents/website$
On this folder, we will iniate Git with the following command:
git init
username@hostname:~/documents/website$ git init
Initialized empty Git repository in /Users/username/documents/website/.git/
Then, we can check the status of our Git repository with:
Git status
We will register ourselves in the Git system to be identified when we make changes:
git config --global user.name "First name"
git config --global user.email "email@example.com"
As an example, image we create or first html page: index.html
touch index.html
If we save this file and take a look at the status of our Git, we will see that a new file is pending being added to our Git project:
In the master branch
No commits yet
Untracked files:
(use "git add {file}..." to include it to what will be committed).
index.html
nothing added to the commit but untracked files present (use "git add" to track them)
We see that we need to add the page to our Git by doing this command:
git add index.html
By adding the file, we added it to the project, but having make a commit yet. So we will edit the content of this page:
sudo nano index.html
This is our first website!
We save and now, we can make our first commit to save the first change.
we start with
git commit
and the value -m
. This value means "message" so we can insert a
message to know what happened in this commit to our website.
git commit -m "Starting the website!"
If we make mor changes to our inde.html file and make a commit, we would ahve 2 timestamps in time of our website.
sudo nano index.html
We add some text to this example file, great!
git commit -m "Editing index.html"
If we made a mistake on step 2, we can go back to the commit in step 1. That allows us to restore a previous version of our webiste if we made an undesirable change. but in my example we hace 2 commits, that is easy to remenber. What if we are 20 people working with 10 commits per day? Impossible to check, se can query the logs of the commits made:
git log
We can move the git folder where we did "git init" to another one:
blm@sb20dell1:/mnt/c/Users/benja/test$ mv GIT/* GIT2/ => We move the content of the folder first
blm@sb20dell1:/mnt/c/Users/benja/test$ mv GIT/.* GIT2/ => we move the hidden folders of Git
mv: cannot move 'GIT/.' to 'GIT2/.': Device or resource busy
mv: 'GIT/..' and 'GIT2/..' are the same file
blm@sb20dell1:/mnt/c/Users/benja/test$ ls -a GIT2/ => we check if everything moved correctly despite the error
. .. .git index.html page.html