Version Control with git (I)

Kosmas Hench

2020-12-03

git basics

Initialize the git repository

1)

cd ~/Desktop
mkdir project_folder
cd project_folder
ls -a
#> .  ..

2)

git int
#> Initialized empty Git repository in /home/usr_name/Desktop/project_folder/.git/

3)

ls -a
#> .  ..  .git

4)

git status
#> On branch master
#> 
#> No commits yet
#> 
#> nothing to commit (create/copy files and use "git add" to track)

Saving Progress

5)

echo "AAA" > A.txt
git status
#> On branch master
#> 
#> No commits yet
#> 
#> Untracked files:
#>   (use "git add <file>..." to include in what will be committed)
#>  A.txt
#> 
#> nothing added to commit but untracked files present (use "git add" to track)

6)

git add A.txt
git status
#> On branch master
#> 
#> No commits yet
#> 
#> Changes to be committed:
#>   (use "git rm --cached <file>..." to unstage)
#>  new file:   A.txt

7)

git commit -m "added A"
#> [master (root-commit) 0a77945] added A
#>  1 file changed, 1 insertion(+)
#>  create mode 100644 A.txt

8)

git status
#> On branch master
#> nothing to commit, working tree clean

Connecting to github

Creating a github repository

9)

git remote add origin https://github.com/usr_name/project_folder.git

10)

git push -u origin master
#> Enumerating objects: 3, done.
#> Counting objects: 100% (3/3), done.
#> Writing objects: 100% (3/3), 203 bytes | 203.00 KiB/s, done.
#> Total 3 (delta 0), reused 0 (delta 0)
#> To https://github.com/usr_name/project_folder.git
#>  * [new branch]      master -> master
#> Branch 'master' set up to track remote branch 'master' from 'origin'.

Pull to local

11)

git pull origin master
#> remote: Enumerating objects: 4, done.
#> remote: Counting objects: 100% (4/4), done.
#> remote: Compressing objects: 100% (2/2), done.
#> remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
#> Unpacking objects: 100% (3/3), 690 bytes | 690.00 KiB/s, done.
#> From https://github.com/usr_name/project_folder
#>  * branch            master     -> FETCH_HEAD
#>    0a77945..34bda33  master     -> origin/master
#> Updating 0a77945..34bda33
#> Fast-forward
#>  README.md | 3 +++
#>  1 file changed, 3 insertions(+)
#>  create mode 100644 README.md

Progress History

12)

git log
#> commit 34bda3348436a786cd7d1eadb9c8960867a9b946 (HEAD -> master, origin/master)
#> Author: usr_name <32705864+usr_name@users.noreply.github.com>
#> Date:   Mon Nov 2 15:56:01 2020 +0100
#> 
#>     Create README.md
#> 
#> commit 0a7794555db4ed5a03380d2016c4abda601f549a
#> Author: usr_name <usr_name@provider.com>
#> Date:   Mon Nov 2 15:31:57 2020 +0100
#> 
#>     added A