|
@ -0,0 +1,96 @@ |
|
|
|
|
|
# Readme # |
|
|
|
|
|
This a repository example to practice the Git basic commands. |
|
|
|
|
|
|
|
|
|
|
|
# First commit # |
|
|
|
|
|
The first commit is the creation of the =file-a.md= file and some lines of code. |
|
|
|
|
|
|
|
|
|
|
|
Then the repository will be enable by |
|
|
|
|
|
|
|
|
|
|
|
``` shell |
|
|
|
|
|
$ git init |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
after that our first file has been created and will be filled with the next lines of code using the =echo= command or =Vim= editor: |
|
|
|
|
|
|
|
|
|
|
|
``` shell |
|
|
|
|
|
vi file-a.md |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
its contents is: |
|
|
|
|
|
|
|
|
|
|
|
``` shell |
|
|
|
|
|
Line 1 |
|
|
|
|
|
Line 2 |
|
|
|
|
|
Line 3 |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
to quit =Vim= editor use =:wq!= in command mode (pressing first the ESC key) |
|
|
|
|
|
|
|
|
|
|
|
Then, we have to add the file we want to track by =git add <file(s)>= command: |
|
|
|
|
|
|
|
|
|
|
|
``` shell |
|
|
|
|
|
$ git add file-a.md |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
To finalize the process, we have to use the =git commit= command: |
|
|
|
|
|
|
|
|
|
|
|
``` shell |
|
|
|
|
|
$ git commit -m "first commit" |
|
|
|
|
|
[master (root-commit) b441ef4] first commit |
|
|
|
|
|
1 file changed, 3 insertions(+) |
|
|
|
|
|
create mode 100644 file-a.md |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
the output from shell should be similar to code section above. Otherwise, you must provide your credentials as a new Git[^1] user with |
|
|
|
|
|
|
|
|
|
|
|
``` shell |
|
|
|
|
|
$ git config --global user.name "Mona Lisa" |
|
|
|
|
|
$ git config --global user.email "my_email@domain.com" |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
# Second commit # |
|
|
|
|
|
After the first commit, we can make some modifications to =file-a.md= file: |
|
|
|
|
|
|
|
|
|
|
|
``` shell |
|
|
|
|
|
Line 0 |
|
|
|
|
|
Line 1 |
|
|
|
|
|
Line 2 |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
then, following the same procedure create and stage your second commit: |
|
|
|
|
|
|
|
|
|
|
|
``` shell |
|
|
|
|
|
$ git status |
|
|
|
|
|
On branch master |
|
|
|
|
|
Changes not staged for commit: |
|
|
|
|
|
(use "git add <file>..." to update what will be committed) |
|
|
|
|
|
(use "git restore <file>..." to discard changes in working directory) |
|
|
|
|
|
modified: file-a.md |
|
|
|
|
|
|
|
|
|
|
|
$ git add file-a.md |
|
|
|
|
|
$ git commit -m "second commit" |
|
|
|
|
|
[master 5fdc115] second commit |
|
|
|
|
|
1 file changed, 1 insertion(+), 1 deletion(-) |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
# Difftool # |
|
|
|
|
|
To compare to commits, in this case our only commits, we will use the =difftool= command |
|
|
|
|
|
|
|
|
|
|
|
``` shell |
|
|
|
|
|
$ git difftool b441ef4 |
|
|
|
|
|
``` |
|
|
|
|
|
here the number =b441ef4= is the commit code number. |
|
|
|
|
|
|
|
|
|
|
|
A more simple way to observe what modifications on the repository is by using =git show= command |
|
|
|
|
|
|
|
|
|
|
|
``` shell |
|
|
|
|
|
$ git show |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
You can observe the log by using: |
|
|
|
|
|
|
|
|
|
|
|
``` shell |
|
|
|
|
|
$ git log --graph --pretty |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
[^1]: Don't forget to run Git Bash or powerShell as Admin user on Windows OS |