Académique Documents
Professionnel Documents
Culture Documents
SVN
Content
The snapshots Git
The distributed Git
Branches and merge
The implementation
The repository
The staging area or the index
Support to using parallel git and svn
The major difference between Git and any other VCS (SVN,
etc) is the way Git thinks about its data. - Scott Chacon.
$ svn ci -m "" .
Handling Branch Conflicts
Switch a branch
$ git checkout iss53
Back to master
$ git checkout master
Merge with master (in iss53 branch)
$ git rebase master
Delete a brach: $git branch d
iss53
Do you think it is simply?
Merging in SVN
It's hardly to merge in a CVCS; therefore branches
tend not to happen
Easily get lost particularly when refactoring start
happening, unless merge to HEAD frequently.
The killer is not only do there include a bunch of changes
already made from trunk. Changes that occurred in the past
to trunk are now showing up again in the merge and SVN
get very confused.
Example:
Merging in Git
Merging in Git is simply
Every commit, git take a snapshot file and stores a
reference to that snapshot. It is not only do you know what
changes need to be made, but also what point in history they
need to be made. So, Git will be able to apply the change
and then play forward the changes.
Merging workflows
Git using the two snapshots pointed
to by the branch tips and the
common ancestor of the two.
Instead of just moving the branch
pointer forward, Git creates a new
snapshot and automatically creates
a new commit that points to it.
This is referred to as a merge
commit and is special in that it has
more than one parent.
So, by using a command:
$ git merge [branch]
It is easy to merge two branch with
only resolve confict if having.
The implementation
SVN
Server
Central repository
Git
Remote Repository
fetch
Client
push
Local Repository
commit
update
reset
The index
checkout
Working directory
commit
add
Working directory
The implementation
SVN
Server
Git
Central repository
Difference
Client
Remote Repository
fetch
push
Local Repository
commit
update
Difference
reset
The index
checkout
Working directory
commit
add
Working directory
Repository
In SVN, there is only a repository that called central
repository, and is located in a server.
Advantage: the projects source code always sync.
Disadvantage:
Might commit unfinished code to server that can
make a lot of conflict and break your prorect.
Cannot preview how projects code effect to if you
dont commit your code.
Difficult to try new feature or another resolve.
Your work doesn't always finish in a short time and right
way, does you?
Repository
Git have two repositories (remote and local) and two
types repository as bare and non-bare.
A "bare" repository contains the version control information,
no working files
It doesn't contain the special .git sub-directory.
It cannot do any change in this repository. A remote
repository is a bare repository.
The repository has to be "bare" in order to accept a push.
only use a "bare" repo to clone, pull from, and push to.
A non-bare repository has working files and .git subdirectory.
It can work in non-bare repository. A local repository is a
non-bare repository.
Repository
The remote repository
Git thing it only a place to share code
Can place any where or you have multi remote server.
In normal, always have a remote repository to sync
code of project
The local repository
Can work offline: commit code, merge code and
resolve conflict.
Only need network when sync source code with
remote repository.
Save your time when commit code.
Easy try or test new way of resolve that dont break
projects source code
The index
Let see this situation to understand the useful of the index.
Suppose that, you start work on some an enhancements.
After screwing around, you give up, leave the half-baked
changes in my working copy. Then, you working again and
have a problem. Using git status to see where your working
is at and having some files changed but not updated such
as a, b, c, d. have two unrelated changes in my working
copy: a, b file are not ready commit and push into remote
server and c, d file needs a commit immediately.
The big problem here is c file it's "tangled" in the sense
that it includes modifications from two different logical
changes and need to tease these changes apart into two
separate commits.