Git B en Vs PDF
Git B en Vs PDF
Do changes
Client Client
Client
Client
3
Commit
---------------------------------
Repository (git database)
/\
-------------------------------- || $ git commit -m «done!»
Working copy
----------------------------
4
Commit
Commit
$ git config --global user.name "John Doe"
$ git config --global user.email [email protected]
--o--o--o
[ master ]
8
Branches
Creating the branch and switching on it
--o--o--o
[ master, new-branch ]
9
Branches
Creating the branch and switching on it
--o-------o-------o
[ master ]
10
Branches
Creating the branch and switching on it
[new-branch]
--o-------o-------o
[ master ]
11
Merge
Join two or more development histories together
[ feature ]
o--o--o
/
--о--о--o--o--o
[ master ]
12
Merge
Join two or more development histories together
[ feature ]
o--o--o
/
--о--о--o--o--o
[ master ]
13
Merge
Join two or more development histories together
[ feature ]
o--o--o-----------------
/ \
--о--о--o--o--o----------------o
[ master ]
14
Merge
Join two or more development histories together
[ feature ]
o--o--o-----------------
/ \
--о--о--o--o--o----------------o
[ master ]
15
Merge
Fast-forward
[ feature ]
o--o--o
/
--о--о--o--o--o
[ master ]
Fast forward merge can be performed when there
is a direct linear path from the source branch to the
target branch.
16
Merge
Fast-forward
--о--о--o--o--o--о--о--о
[ master, feature ]
17
Rebase
Reapply commits on top of another base tip
--о--о--o--o--o [ master ]
\
о--о [ server ]
18
Rebase
Reapply commits on top of another base tip
--о--о--o--o--o [ master ]
\
о--о [ server ]
19
Rebase
Reapply commits on top of another base tip
--о--о--o--o--o [ master ]
\
о--о [ server ]
20
Remote
Repository
$ git clone https://git.itransition.com/project/site.git
Cloning into site
...
$ git remote -v
origin https://git.itransition.com/project/site.git
21
Remote
Repository
Fetch from and integrate with a local branch
$ git pull
1. $ git fetch
[ origin/master ]
o--o--o
--о--о--o--o--o--о-----o
[ master ]
22
Remote
Repository
Fetch from and integrate with a local branch
$ git pull
2. $ git merge
[ origin/master ]
o--o--o
/ \
--о--о--o--o--o--о-----o
[ master ]
23
Remote
Repository
Publish your changes - push
o--o--o
/ \
--о--о--o--o--o--о-----o
[ master, origin/master ]
$ git push origin master
24
Revert commit changes
Git Revert:
---о---о---о---о
[ master ]
25
Revert commit changes
Git Revert:
---о---о---о---о---о
[ master ]
26
Revert commit changes
What if you need to reset your working copy to
some exact state?
27
Revert commit changes
What if you need to reset your working copy to
some exact state?
28
Revert commit changes
What if you need to reset your working copy to
some exact state?
29
Revert commit changes
$ git reset --hard 12345
о--о [ master ]
/
--о--о--о--о
[ origin/master ]
30
.GITIGNORE
## Directory-based project format:
.idea/
# Logs
logs
*.log
# Runtime data
pids
*.pid
*.seed
# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
Gitflow
There is a “development” branch for the test purposes
--о--о--о--о--о [ development ]
32
Gitflow
There are “feature” branches for the feature development
--о--о--о--о--о [ development ]
\
о--о--о [ feature ]
33
Gitflow
There are “release-candidate” branches
о--о--о [ release-2.1 ]
/
--о--о--о--о--о [ development ]
\
о--о--о [ feature ]
34
Gitflow
There is a “master” branch for releases
.--о--о--о [ master ]
|
|
| о--о--о [ release-2.1 ]
| /
--о--о--о--о--о [ development ]
\
о--о--о [ feature ]
35
Gitflow
There are “hotfix” branches
.--о--о--о [ master ]
| \
| о--о [ hotfix ]
| о--о--о [ release-2.1 ]
| /
--о--о--о--о--о [ development ]
\
о--о--о [ feature ]
36
Gitflow
.--о--о--о [ master ]
| \
| о--о [ hotfix ]
| о--о--о [ release-2.1 ]
| /
--о--о--о--о--о--о [ development ]
\ /
о--о--о-------
37
Gitflow
.--о--о--о--о [ master ]
| \ /
| о--о---
| о--о--о [ release-2.1 ]
| /
--о--о--о--о--о--о [ development ]
\ /
о--о--о-------
38
Gitflow
<2.1>
.--о--о--о--о---о [ master ]
| \ / /
| о--о--- /
| о--о--о-----
| / \
--о--о--о--о--о--о--о [ development ]
\ /
о--о--о-------
39
Pros
• Distributed
• Fast
• Light weight branches
40
Cons
• Complexity
41
What to use
• Console
• Built-in IDE or notepad tools
• GitKraken
• SourceTree
Where to host
• GitHub
• GitLab
• Bitbucket
What to read
Scott Chacon and Ben Straub ‘Pro Git’
https://git-scm.com/book/pl/v2
Questions?