a version-control system
Paweł Mleczko
Faculty of Mathematics and Computer Science
Adam Mickiewicz University in Poznań
GIT is a version control system for tracking changes and exchange files among users.
Three friends works on the same document in teh same time.
How can they do this?
The power of text files!
Linus Torvalds (born 1969), Finnish programmer, the author of Linux kernel.
A test repository at GitHub
$ git config --global user.name "First name Last name"
$ git config --global core.editor nano
$ git config --global user.email jannowak@example.com
$ git init
git clone 'repozytorium'
for example
$ git clone git@github.com:pml-pml/nidn2017.git
Cloning into 'nidn2017'...
The authenticity of host 'github.com (192.30.253.113)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.253.113' (RSA) to the list of known hosts.
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
lorem.txt
nothing added to commit but untracked files present (use "git add" to track)
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: lorem.txt
$ git add lorem.txt
$ git commit -m "dodanie pliku z fragmentem lorem ipsum"
[master ff54873] dodanie pliku z fragmentem lorem ipsum
1 file changed, 1 insertion(+)
create mode 100644 lorem.txt
$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
$ git push
Counting objects: 3, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 566 bytes | 566.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To github.com:pml-pml/nidn2017.git
f05826b..ff54873 master -> master
$ git push
Counting objects: 3, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 566 bytes | 566.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To github.com:pml-pml/nidn2017.git
f05826b..ff54873 master -> master
$ git pull
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From github.com:pml-pml/nidn2017
ff54873..6faf81e master -> origin/master
Updating ff54873..6faf81e
Fast-forward
lorem.txt | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
$ git pull
$ git push
Username for 'https://github.com': pml-pml
Password for 'https://pml-pml@github.com':
To https://github.com/pml-pml/nidn2017.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/pml-pml/nidn2017.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
$ git pull
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 1), reused 3 (delta 1), pack-reused 0
Unpacking objects: 100% (3/3), done.
From https://github.com/pml-pml/nidn2017
6faf81e..a54bb68 master -> origin/master
Auto-merging lorem.txt
CONFLICT (content): Merge conflict in lorem.txt
Automatic merge failed; fix conflicts and then commit the result.
$ git log
commit 1c173d64cf80e2a8cfb7b22ff76f891f23c329cd (HEAD -> master, origin/master, origin/HEAD)
Merge: 03195c9 a54bb68
Author: Paweł Mleczko <pml@amu.edu.pl>
Date: Tue Oct 24 12:59:01 2017 +0200
rozwiązanie konfliktu wyróżnienie/podkreślenie
commit 03195c925dcd30085d7cd52a663499eec99e5f2b
Author: Paweł Mleczko <pml@amu.edu.pl>
Date: Tue Oct 24 12:51:01 2017 +0200
wyróżnienie drugiego słowa w pierwszym akapicie
commit a54bb68b97338505cd6ac7d8f258bf275b37086e
Author: Paweł Mleczko <pml@amu.edu.pl>
Date: Tue Oct 24 12:49:16 2017 +0200
podkreślenie drugiego słowa w pierwszym akapicie
commit 6faf81e39188194c53200ba1352a88effb8bb439
Author: Paweł Mleczko <pml@amu.edu.pl>
Date: Mon Oct 23 17:24:30 2017 +0200
dopisanie drugiego akapitu
$ git show
commit 1c173d64cf80e2a8cfb7b22ff76f891f23c329cd (HEAD -> master, origin/master, origin/HEAD)
Merge: 03195c9 a54bb68
Author: Paweł Mleczko <pml@amu.edu.pl>
Date: Tue Oct 24 12:59:01 2017 +0200
rozwiązanie konfliktu wyróżnienie/podkreślenie
$ git clone git@github.com:pml-pml/nidn2017.git
Cloning into 'nidn2017'...
The authenticity of host 'github.com (192.30.253.113)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.253.113' (RSA) to the list of known hosts.
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.
pros
cons
Manual
For example:
In most cases no tracking changes possibilities.