Системы контроля версий (VCS)

Теория патчей

Distributed Version Control

Central Version Control

Существующие системы

  • CVS
  • Subversion
  • Git
  • Mercurial
  • Bazaar
  • ...

http://git-scm.com/

https://github.com/

$ git init

Initialized empty Git repository in /.git/


$ git status
 

# On branch master
#
# Initial commit
#
nothing to commit (create/copy files and use "git add" to track)




$ git status
 

# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#	README.md
nothing added to commit but untracked files present (use "git add" to track)
$ git add README.md

$ git status
 

# On branch master
#
# Initial commit
#
# Changes to be committed:
#   (use "git rm --cached <file>..." to unstage)
#
#	new file:   README.md
#


$ git commit -m "Add description of our first project"

[master (root-commit) 20b5ccd] Add description of our first project
 1 file changed, 1 insertion(+)
 create mode 100644 README.md
$ git log

commit b652edfd888cd3d5e7fcb857d0dabc5a0fcb5e28
Author: Andrii Kucherenko <Andrii_Kucherenko@epam.com>
Date:   Sat Oct 10 08:30:00 2020 -0500

    Add description of our first project

$ git remote add origin git@github.com:kucherenko/git-classes.git


$ git push -u origin master
 

Branch master set up to track remote branch master from origin.

$ git pull
 

Updating 3852b4d..3e70b0f
Fast-forward
 README.md |    1 +
 1 file changed, 1 insertion(+)
 create mode 100644 README.md
$ git diff HEAD
 

diff --git a/README.md b/README.md
index 7d8d808..e725ef6 100644
--- a/octocat.txt
+++ b/octocat.txt
@@ -1 +1 @@
-Hello
+Ololo

$ git reset README.md


$ git checkout -- README.md
$ git branch other_vision


$ git checkout other_vision
 

Switched to branch 'other_vision'

//make changes


$ git checkout master


$ git merge other_vision


Updating 3852b4d..ec6888b
Fast-forward
 blue_octocat.txt             |    1 -
 octocat.txt                  |    1 -
 octofamily/baby_octocat.txt  |    1 -
 octofamily/momma_octocat.txt |    1 -
 red_octocat.txt              |    1 -
 5 files changed, 5 deletions(-)
 delete mode 100644 blue_octocat.txt
 delete mode 100644 octocat.txt
 delete mode 100644 octofamily/baby_octocat.txt
 delete mode 100644 octofamily/momma_octocat.txt
 delete mode 100644 red_octocat.txt
$ git branch -d other_vision
 

Deleted branch other_vision (was ec6888b).
$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#      modified:   index.html
#
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#
#      modified:   lib/simplegit.rb
#

$ git stash
Saved working directory and index state \
  "WIP on master: 049d078 added the index file"
HEAD is now at 049d078 added the index file
(To restore them type "git stash apply")

$ git status
# On branch master
nothing to commit, working directory clean
$ git stash list
stash@{0}: WIP on master: 049d078 added the index file
stash@{1}: WIP on master: c264051 Revert "added file_size"
stash@{2}: WIP on master: 21d80a5 added number to log


$ git stash apply
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#
#      modified:   index.html
#      modified:   lib/simplegit.rb
#

Спасибо! Вопросы!

Системы контроля версий (VCS)

By Andrey Kucherenko

Системы контроля версий (VCS)

  • 1,175
Loading comments...

More from Andrey Kucherenko