22
April 3, 2009 1 Getting Started with (Distributed) Version Control Because what other tools have a blame command? John Paulett jhcore.com

Getting Started with (Distributed) Version Control

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Getting Started with (Distributed) Version Control

April 3, 2009 1

Getting Started with (Distributed) Version Control

Because what other tools have a blame command?

John Paulettjhcore.com

Page 2: Getting Started with (Distributed) Version Control

April 3, 2009 2

Collaboration

Bob adds foo() to main.c while Alice edits bar() in main.c. How do they merge?

Please do not share code via Windows file sharing!

Page 3: Getting Started with (Distributed) Version Control

April 3, 2009 3

History

"Oops, we screwed up the release, can we roll back to the last production version?"

“Who added this bug?”

Page 4: Getting Started with (Distributed) Version Control

April 3, 2009 4

Backup

"The Photoshop keygen gave me a virus."

Sharing files between computers

Page 5: Getting Started with (Distributed) Version Control

April 3, 2009 5

Personally

Open source projects

Personal projects (master's thesis code)

School files (papers, assignments)

Config files (~/.ssh/config, ~/.hgrc)

Page 6: Getting Started with (Distributed) Version Control

April 3, 2009 6

Centeralized vs Decentralized

Cathedral vs Bazaar

Offline commits● More atomic commits

Forking is encouraged● Can keep private until ready

http://en.wikipedia.org/wiki/index.html?curid=755487

Page 7: Getting Started with (Distributed) Version Control

April 3, 2009 7

VCS Tools

● cp -R project project.old● RCS● CVS● Subversion● Perforce● Visual SafeSource● ClearCase● ...

Page 8: Getting Started with (Distributed) Version Control

April 3, 2009 8

Distributed VCS Tools

● Mercurial● Git● Bazaar● Monotone● Darcs

● Plastic SCM● SVK● Codeville● GNU arch● Bitkeeper● ...

Page 9: Getting Started with (Distributed) Version Control

April 3, 2009 9

Which one?

The new “vim vs emacs”

(emacs is better)http://xkcd.com/378/

Page 10: Getting Started with (Distributed) Version Control

April 3, 2009 10

Mercurial

● OpenJDK● Solaris● Python● Mozilla● Netbeans

Page 11: Getting Started with (Distributed) Version Control

April 3, 2009 11

Workflow

1. Checkout / Start repo

2. Add / Remove / Edit files

3. Commit your changes

4. Push changes

5. Update / Merge

6. Go to #2

Page 12: Getting Started with (Distributed) Version Control

April 3, 2009 12

Simple Example

# checkout the repository

hg clone http://bitbucket.org/johnpaulett/python-hl7/

# add the file server.py to be under version control

hg add server.py

# commit the file

hg commit -m "Added a single threaded HL7 socket server."

Page 13: Getting Started with (Distributed) Version Control

April 3, 2009 13

Simple Example

# Send my changes to bitbucket

hg push

# Pull others' changes from bitbucket

hg pull

hg update

# Merge in anyone else's changes

hg merge

Page 14: Getting Started with (Distributed) Version Control

April 3, 2009 14

Useful Commands

Start a repository:

hg init my-emr

Find out who changed what in which version:

hg blame

hg log

Page 15: Getting Started with (Distributed) Version Control

April 3, 2009 15

But I Hate the Command Line

TortoiseHg

Page 16: Getting Started with (Distributed) Version Control

April 3, 2009 16

But I Hate the Command Line

MercurialEclipse

Page 17: Getting Started with (Distributed) Version Control

April 3, 2009 17

Being a DVCS Dog

"On the Internet, nobody knows that you're a dog."

hgsubversion

git-svn

New Yorker, 1993

Page 18: Getting Started with (Distributed) Version Control

April 3, 2009 18

Hosting

● BitBucket (or GitHub for git)● Sourceforge

● hg serve● SSH● hgweb (via Apache)

Page 19: Getting Started with (Distributed) Version Control

April 3, 2009 19

Page 20: Getting Started with (Distributed) Version Control

April 3, 2009 20

Bad Commit Messages

Not Atomic

“Fixed a few bugs in the interface. Added an ID field. Removed a couple unnecessary functions. Refactored the context check.”

Not Specific

“Fixed some bugs.”http://lbrandy.com/blog/2009/03/writing-better-commit-messages/

Page 21: Getting Started with (Distributed) Version Control

April 3, 2009 21

Customizing

hgrc

Set locations, username, plugins

.hgignore

Ignore unwanted files (*.class, *.pyc, *.log)

Page 22: Getting Started with (Distributed) Version Control

April 3, 2009 22

More Info

● http://www.slideshare.net/johnpaulett/getting-started-with-distributed-version-control

● http://www.selenic.com/mercurial/wiki/

● http://betterexplained.com/articles/intro-to-distributed-version-control-illustrated/

● http://bitbucket.org/

● http://joshcarter.com/productivity/svn_hg_git_for_home_directory

● http://lbrandy.com/blog/2009/03/writing-better-commit-messages/

● http://bitbucket.org/mercurialeclipse/main/wiki/Home

● http://bitbucket.org/durin42/hgsubversion/wiki/Home

● http://bitbucket.org/tortoisehg/stable/wiki/Home