space, → | next slide |
← | previous slide |
d | debug mode |
## <ret> | go to slide # |
c | table of contents (vi) |
f | toggle footer |
r | reload slides |
z | toggle help (this) |
Scott Becker, Dev Tools / Jive Apps Framework
Use the arrow keys to move through the persentation!
All local, all the time
One server, one repository, many clients, many checkouts
One repository per client or server
# Redhat / Fedora
$ yum install git-core
# Debian / Ubuntu
$ apt-get install git-core
# Mac OS X
http://code.google.com/p/git-osx-installer
# Windows
http://code.google.com/p/msysgit
$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com
Man Pages
$ git help <verb>
$ git <verb> --help
$ git clone git@github.com:jivesoftware/jiverscripts.git
Cloning into jiverscripts...
remote: Counting objects: 399, done.
remote: Compressing objects: 100% (351/351), done.
remote: Total 399 (delta 163), reused 162 (delta 26)
Receiving objects: 100% (399/399), 968.16 KiB | 154 KiB/s, done.
Resolving deltas: 100% (163/163), done.
$ mkdir gitpreso
$ cd gitpreso
$ git init
Initialized empty Git repository in ~/gitpreso/.git/
$ git status
# On branch master
#
# Initial commit
#
nothing to commit (create/copy files & use "git add" to track)
$ echo "This is a demo." > README
$ echo "puts 'Hi Jivers'" > say_hi.rb
$ git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in commit)
#
# README
# say_hi.rb
nothing added to commit but untracked files present
(use "git add" to track)
$ git add README
$ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: README
#
# Untracked files:
# (use "git add <file>..." to include in commit)
#
# say_hi.rb
$ git add say_hi.rb
$ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: README
# new file: say_hi.rb
#
$ git commit -m 'initial commit'
[master (root-commit) 3c85a9a] initial commit
2 files changed, 2 insertions(+), 0 deletions(-)
create mode 100644 README
create mode 100644 say_hi.rb
$ git status
# On branch master
nothing to commit (working directory clean)
$ echo "Another line." >> README
$ git status
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: README
#
no changes added to commit (use "git add" and/or "git commit -a")
$ git add README
$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: README
#
$ echo "Yet another line." >> README
$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: README
#
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: README
#
$ echo "And another new line." >> README
$ git commit -am 'add and commit in one'
[master af695bc] add and commit in one
1 files changed, 3 insertions(+), 0 deletions(-)
$ touch tmp.txt
$ git status
# On branch master
# Untracked files:
# (use "git add <file>..." to include in commit)
#
# tmp.txt
nothing added to commit but untracked files present
$ echo "tmp.txt" > .gitignore
$ git status
# On branch master
# Untracked files:
# (use "git add <file>..." to include in commit)
#
# .gitignore
nothing added to commit but untracked files present
$ git add .gitignore
$ git commit -m 'ignore tmp.txt'
$ git log
commit be4a5769174d9b085c804a3695c486dd5931f43a
Author: Scott Becker <scott.becker@jivesoftware.com>
Date: Thu Feb 24 22:03:38 2011 -0800
ignore tmp.txt
commit af695bce42aa0791190cee6e5524d97cd78a6f8f
Author: Scott Becker <scott.becker@jivesoftware.com>
Date: Thu Feb 24 21:54:18 2011 -0800
add and commit in one
commit 3c85a9a386de5aec0593367c9a461fc2c933cf7f
Author: Scott Becker <scott.becker@jivesoftware.com>
Date: Thu Feb 24 16:56:24 2011 -0800
initial commit
$ git mv README README.txt
$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# renamed: README -> README.txt
#
$ git commit -m 'renamed README to README.txt'
[master ca2e364] renamed README to README.txt
1 files changed, 0 insertions(+), 0 deletions(-)
rename README => README.txt (100%)
$ git rm say_hi.rb
rm 'say_hi.rb'
$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# deleted: say_hi.rb
#
$ git commit -m 'removed say_hi.rb'
[master d5f291b] removed say_hi.rb
1 files changed, 0 insertions(+), 1 deletions(-)
delete mode 100644 say_hi.rb
$ git clone git@github.com:jivesoftware/jiverscripts.git
$ cd jiverscripts/
$ git remote
origin
$ git remote -v
origin git@github.com:jivesoftware/jiverscripts.git (fetch)
origin git@github.com:jivesoftware/jiverscripts.git (push)
$ cd gitpreso
$ git remote add origin git@github.com:sbecker/gitpreso.git
$ git push -u origin master
Counting objects: 14, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (11/11), done.
Writing objects: 100% (14/14), 1.23 KiB, done.
Total 14 (delta 2), reused 0 (delta 0)
To git@github.com:sbecker/gitpreso.git
* [new branch] master -> master
Branch master set up to track remote branch master
from origin.
$ echo "So very fine." >> README.txt
$ git commit -am 'Added another line to readme.'
[master 7b443d8] Added another line to readme.
1 files changed, 1 insertions(+), 0 deletions(-)
$ git push origin master
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 337 bytes, done.
Total 3 (delta 1), reused 0 (delta 0)
To git@github.com:sbecker/gitpreso.git
d5f291b..7b443d8 master -> master
$ git pull
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 1), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From github.com:sbecker/gitpreso
d5f291b..7b443d8 master -> origin/master
Updating d5f291b..7b443d8
Fast-forward
README.txt | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
$ git checkout -b crazy_idea
Switched to a new branch 'crazy_idea'
$ echo "puts 'super fast code'" > super_fast.rb
$ git add super_fast.rb
$ git commit -m 'super fast refactor'
[crazy_idea 95e5afc] super fast refactor
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 super_fast.rb
$ git checkout master -b hotfix
Switched to a new branch 'hotfix'
$ echo "Fix issue." >> README.txt # pretend!
$ git commit -m 'fix issue'
[hotfix 0e1a30a] fix issue
1 files changed, 1 insertions(+), 0 deletions(-)
$ git checkout master
Switched to branch 'master'
$ git merge hotfix
Updating 7b443d8..0e1a30a
Fast-forward
README.txt | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
$ git branch -d hotfix
Deleted branch hotfix (was 0e1a30a).
$ git push
...
$ git checkout crazy_idea
Switched to branch 'crazy_idea'
$ # lets merge in that hotfix
$ git rebase master
First, rewinding head to replay your work on top of it...
Applying: super fast refactor
$ # we decide it works, passes tests, etc.. lets merge it in
$ git checkout master
$ git merge crazy_idea
Updating 0e1a30a..9a81c6c
Fast-forward
super_fast.rb | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 super_fast.rb
$ git branch -d crazy_idea
Deleted branch crazy_idea (was 9a81c6c).
$ git svn clone http://svn.example.com/svn/repos/foo/apps
Initialized empty Git repository in /Users/scott.becker/Archive/Development/gitsvn/apps/.git/
W: Ignoring error from SVN, path probably does not exist: (160013): Filesystem has no item: '/svn/repos/!svn/bc/100/jaf/apps' path not found
W: Do not be alarmed at the above message git-svn is just searching aggressively for old history.
This may take a while on large repositories
W: Ignoring error from SVN, path probably does not exist: (160013): Filesystem has no item: '/svn/repos/!svn/bc/100/jaf/apps' path not found
W: Do not be alarmed at the above message git-svn is just searching aggressively for old history.
This may take a while on large repositories
r115752 = e0f1fbfe772264fdba470170256a97ba0cda347b (refs/remotes/git-svn)
A README
W: +empty_dir: demo
W: +empty_dir: example
W: +empty_dir: test
r115755 = c2af7679d48033febec49a9192830f78b7b2041b (refs/remotes/git-svn)
A test/openclient-js/test_gadget_feature.xml
A example/openclient-js/microblogs.xml
...
$ cd apps/
$ git log
commit e056e56329f235d91d1305299b0fdd63d58ee6ac
Author: author.name <author.name@c71dbd84-28fa-0310-abbe-db3d66cda40d>
Date: Tue Feb 22 22:49:24 2011 +0000
Made a change to foo.
git-svn-id: http://svn.jiveland.com/svn/repos/foo/apps@139257 c71dbd84-28fa-0310-abbe-db3d66cda40d
commit 19e95b883b532fb1ca1e77d54e0d47b6158cab91
Author: author.name <author.name@c71dbd84-28fa-0310-abbe-db3d66cda40d>
Date: Tue Feb 22 01:43:14 2011 +0000
Made a change to bar.
git-svn-id: http://svn.jiveland.com/svn/repos/foo/apps@139172 c71dbd84-28fa-0310-abbe-db3d66cda40d
$ vi README
...updated README file...
$ git commit -am 'updated README'
[master 62e6ea0] updated README
1 files changed, 1 insertions(+), 0 deletions(-)
$ git svn dcommit
Committing to http://svn.jiveland.com/svn/repos/foo/apps ...
M README
Committed r139636
M README
r139636 = 6cbe2cfc5d1d38e78f735ee26e67b3ef51aff379 (refs/remotes/git-svn)
No changes between current HEAD and refs/remotes/git-svn
Resetting to the latest refs/remotes/git-svn
$ ...made another change to README elsewhere
$ ...switch back to git-svn repo and pull in changes
$ git svn rebase
M README
r139638 = 11d9b1cbf27bb4807d743e93d13e987a3eefc79f (refs/remotes/git-svn)
First, rewinding head to replay your work on top of it...
Fast-forwarded master to refs/remotes/git-svn.