Without version control - backup.zip
One developer - ok.
Two developers - danger!
Five developers - madness!
copy to separate directory
(project-25-12-2015, backup-qweqwe15, New Folder 283, ...)
problems? weaknesses? milestones?
problems? weaknesses? milestones?
is a database of all the edits to,
and/or historical versions (snapshots) of your project.
local repository and the central (remote) repository
your personal (local) copy of repository
action to copy a remote repository to your local
action, that you made to share your changes with other teammates.
uploading your local changes to repository
a version of document
action, that you made to make your working copy up-to-date with remote repository
a named set of changes
a copy of repository
a main branch for work
a case, when few users made not-similar changes in one file
a latest version for branch
an action to combine independent changes to one version
a label for specific version of document
there is just one repository.
there are multiple repositories
the final version is a merge of original version and edit.
occurs when two different users make simultaneous, different changes to the same line of a file
clone the project (tree of files/directories)
from remote to local (filesystem)
with specific version
is a:
because:
.git/
Any sequence of bytes -> (hash function) -> hash
Every object (commit, state, action) has own SHA1.
1 chanse in 175.000.000
$ git config
$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com
$ git config --list
$ git config user.name
$ git help command
$ git command --help
$ man git-command
# initializes a directory as a Git repository
$ git init
# copy a git repository so you can add to it
$ git clone git://github.com/schacon/simplegit.git
...
...
Moving from Working Area to Index (add) and to Repository (commit)).
checkout
...
...
adds file contents to the staging area
$ git status -s
?? README
?? hello.rb
$ git add README hello.rb
$ git add *.rb
$ git status -s
A README
A hello.rb
# edit & save the "README" file
$ git status -s
AM README
A hello.rb
adds file contents to the staging area
$ git status -s
AM README
A hello.rb
$ git status -s
M README
D hello.rb
shows diff of what is staged and what is modified but unstaged
$ vim hello.rb
$ git status -s
M hello.rb
$ git diff
diff --git a/hello.rb b/hello.rb
index d62ac43..8d15d50 100644
--- a/hello.rb
+++ b/hello.rb
@@ -1,7 +1,7 @@
class HelloWorld
def self.hello
- puts "hello world"
+ puts "hola mundo"
end
end
records a snapshot of the staging area
$ git config --global user.name 'Your Name'
$ git config --global user.email you@somedomain.com
$ git add hello.rb
$ git status -s
M hello.rb
$ git commit -m 'my hola mundo changes'
[master 68aa034] my hola mundo changes
1 files changed, 2 insertions(+), 1 deletions(-)
$ git status
# On branch master
nothing to commit (working directory clean)
undo changes and commits
$ git status -s
M README
M hello.rb
$ git add .
$ git status -s
M README
M hello.rb
$ git reset HEAD -- hello.rb
Unstaged changes after reset:
M hello.rb
$ git status -s
M README
M hello.rb
remove files from the staging area
$ git rm hello.rb
list, add and delete remote repository aliases
$ git remote
origin
$ git remote -v
origin git@github.com:github/git-reference.git (fetch)
origin git@github.com:github/git-reference.git (push)
download new branches and data from a remote repository
fetch from a remote repo and try to merge into the current branch
$ git fetch github
remote: Counting objects: 4006, done.
remote: Compressing objects: 100% (1322/1322), done.
remote: Total 2783 (delta 1526), reused 2587 (delta 1387)
Receiving objects: 100% (2783/2783), 1.23 MiB | 10 KiB/s, done.
Resolving deltas: 100% (1526/1526), completed with 387 local objects.
From github.com:schacon/hw
8e29b09..c7c5a10 master -> github/master
0709fdc..d4ccf73 c-langs -> github/c-langs
6684f82..ae06d2b java -> github/java
* [new branch] ada -> github/ada
* [new branch] lisp -> github/lisp
push your new branches and data to a remote repository
$ git push github master
Counting objects: 25, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (25/25), done.
Writing objects: 100% (25/25), 2.43 KiB, done.
Total 25 (delta 4), reused 0 (delta 0)
To git@github.com:schacon/hw.git
* [new branch] master -> master
filter your commit history
$ git log --author=Linus --oneline -5
81b50f3 Move 'builtin-*' into a 'builtin/' subdirectory
3bb7256 make "index-pack" a built-in
377d027 make "git pack-redundant" a built-in
b532581 make "git unpack-file" a built-in
112dd51 make "mktag" a built-iner
$ git diff v0.9 --stat
README | 2 +-
ruby.rb | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
http://pages.github.com/
http://your-name.github.io/your-repo/
is a publicy visible clone.
contributor owns fork.
TBD
write a good commit message
to indicate the purpose of the changes
each commit should have a single purpose
and should completely implement that purpose
Little and often commits!
make a commit with specific files
CVCS: commit when you're ready.
DVCS: commit when you want. push when you're ready!
Save-points!
work with the most up-to-date version of the files as possible
share a logical unit of work with your colleagues as soon as possible
strive to avoid conflicts.
to talk with teammates is the best way to avoid conflicts
they aren't necessary in version control