Skip to content

Test drive Git

October 11, 2008

I read some interesting articles about Git these days and looks like it is really useful when you don’t have any internet access ( plane , no wifi coffee shop … ) . I can have your own local copy of repository ( because hard disk is so cheap !) .

To install Git on my Mac OS X , I used sudo port install git-core ( or maybe git , i am old, hard to remember ;( ). To mimic some of the centralized VCS , I did these tests.

1. Test to create(init) a repo

[jqyao@localhost ~/dev]$ mkdir git-test
[jqyao@localhost ~/dev]$ cd git-test/
[jqyao@localhost ~/dev/git-test]$ touch a.txt b.txt
[jqyao@localhost ~/dev/git-test]$ git init
Initialized empty Git repository in /Users/jqyao/dev/git-test/.git/
[jqyao@localhost ~/dev/git-test]$ git add .
[jqyao@localhost ~/dev/git-test]$ git commit -m “init repo”
Created initial commit a78b4f1: init repo
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 a.txt
create mode 100644 b.txt
[jqyao@localhost ~/dev/git-test]$ ls
a.txt   b.txt

2. Test to clone a repo so that I can work on my local copy

[jqyao@localhost ~/dev]$ git clone -l git-test/ git-test-clone1
Initialized empty Git repository in /Users/jqyao/dev/git-test-clone1/.git/
[jqyao@localhost ~/dev]$ ll git-test-clone1/
total 0
-rw-r–r–  1 jqyao  users  0 Oct 10 17:46 a.txt
-rw-r–r–  1 jqyao  users  0 Oct 10 17:46 b.txt

3.Test to work in origin repo and check if we can get those change from clone

jqyao@localhost ~/dev/git-test]$ touch c.txt
[jqyao@localhost ~/dev/git-test]$ git add .
[jqyao@localhost ~/dev/git-test]$ git commit -m “add c.txt”
Created commit de09435: add c.txt
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 c.txt
[jqyao@localhost ~/dev/git-test]$ cd ../git-test-clone1/
[jqyao@localhost ~/dev/git-test-clone1]$ git pull
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 2 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (2/2), done.
From /Users/jqyao/dev/git-test//
a78b4f1..de09435  master     -> origin/master
Updating a78b4f1..de09435
Fast forward
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 c.txt
[jqyao@localhost ~/dev/git-test-clone1]$ ls
a.txt   b.txt   c.txt
[jqyao@localhost ~/dev/git-test-clone1]$

4. Test to do some work in clone and push to origin repo
[jqyao@localhost ~/dev/git-test-clone1]$ touch d.txt
[jqyao@localhost ~/dev/git-test-clone1]$ git add .
[jqyao@localhost ~/dev/git-test-clone1]$ git commit -m “clone1 add d.txt”
Created commit 9eb3513: clone1 add d.txt
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 d.txt
[jqyao@localhost ~/dev/git-test-clone1]$ git push origin master
Counting objects: 3, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 265 bytes, done.
Total 2 (delta 1), reused 0 (delta 0)
Unpacking objects: 100% (2/2), done.
To /Users/jqyao/dev/git-test//.git
de09435..9eb3513  master -> master
[jqyao@localhost ~/dev/git-test-clone1]$ cd ../git-test
[jqyao@localhost ~/dev/git-test]$ ls
a.txt   b.txt   c.txt
[jqyao@localhost ~/dev/git-test]$ git checkout
[jqyao@localhost ~/dev/git-test]$ ls
a.txt   b.txt   c.txt   d.txt

5. Test to do work in clone2 and pull from clone 1
[jqyao@localhost ~/dev/git-test]$ cd ..
[jqyao@localhost ~/dev]$ git clone -l git-test git-test-clone2
Initialized empty Git repository in /Users/jqyao/dev/git-test-clone2/.git/
[jqyao@localhost ~/dev]$ cd git-test-clone2/
[jqyao@localhost ~/dev/git-test-clone2]$ ls
a.txt   b.txt   c.txt   d.txt
[jqyao@localhost ~/dev/git-test-clone2]$ touch e.txt
[jqyao@localhost ~/dev/git-test-clone2]$ git add .
[jqyao@localhost ~/dev/git-test-clone2]$ git commit -m “e.txt added by clone2”
Created commit 67c5e33: e.txt added by clone2
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 e.txt
[jqyao@localhost ~/dev/git-test-clone2]$ git push origin master
Counting objects: 3, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 245 bytes, done.
Total 2 (delta 1), reused 0 (delta 0)
Unpacking objects: 100% (2/2), done.
To /Users/jqyao/dev/git-test/.git
9eb3513..67c5e33  master -> master
[jqyao@localhost ~/dev/git-test-clone2]$ cd ../git-test-clone1/
[jqyao@localhost ~/dev/git-test-clone1]$ ls
a.txt   b.txt   c.txt   d.txt
[jqyao@localhost ~/dev/git-test-clone1]$ git pull
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 2 (delta 1), reused 0 (delta 0)
Unpacking objects: 100% (2/2), done.
From /Users/jqyao/dev/git-test//
9eb3513..67c5e33  master     -> origin/master
Updating 9eb3513..67c5e33
Fast forward
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 e.txt
[jqyao@localhost ~/dev/git-test-clone1]$ ls
a.txt   b.txt   c.txt   d.txt   e.txt

Actually these tests are to mimic how the centralized VCS works.

1.Create a repo

2.Worker 1 can pull source code from central repo and do work. After finishing his work, he can push back to central repo.

3.Worker 2 can work on source code and push back (check in ) central repo. Then worker 1 can pull(check out ) the  changes and continue work .

I am just trying to understand Git in the old way and will test more distributed way. will keep you posted 😉

Enjoy !

Advertisements

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: