source control

46

Upload: anushka-perera

Post on 13-Apr-2017

185 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Source control
Page 2: Source control

Content Version control Advantages & disadvantages of GIT GIT basics Subversion TortoiseSVN How to use SVN Rules on using SVN

2

Page 3: Source control

Version Control Version control (or revision control, or source control) is all about managing multiple versions of documents, programs, web sites, etc.Some well-known version control systems are CVS, Subversion, Mercurial, and Git.Distributed systems like Mercurial and Git are newer and are

gradually replacing centralized systems like CVS and Subversion.

3

Page 4: Source control

Local Version Control Local version-control method of choice is to copy files

into another directory(perhaps a time-stamped directory, if they’re clever).

This approach is very common because it is so simple, but

it is also incredibly error prone.

Ex :-• RCS

4

Page 5: Source control

Local Version Control5

Page 6: Source control

Centralized Version Control Traditional version control system.

• Server with database• Clients have a working version

Challenges• Multi-developer conflicts• Client/server communication

Ex :-• CVS• Subversion• Visual source safe

6

Page 7: Source control

Centralized Version Control7

Page 8: Source control

Distributed Version Control Authoritative server by convention only. Every working checkout is a repository. Get version control even when detached. Backups are trivial. Ex :-

• Mercurial• BitKeeper• Darcs• Bazaar

8

Page 9: Source control

Distributed Version Control9

Page 10: Source control

Advantages of GIT Resilience• No one repository has more data than any other

Speed• Very fast operations compared to other VCS (I’m

looking at you CVS and Subversion) Space• Compression can be done across repository not just

per file• Minimizes local size as well as push/pull data transfers

Simplicity• Object model is very simple

Large user base with robust tools

10

Page 11: Source control

Disadvantages of GIT Definite learning curve, especially for those used to

centralized systems.• Can sometimes seem overwhelming to learn

Conceptual difference Huge amount of commends

11

Page 12: Source control

GIT Basics Storing data as changes to a base

version of each file.

12

Page 13: Source control

Storing data as snapshots of the project over time.

13

Page 14: Source control

Working directory,staging area, and Git directory.

14

Page 15: Source control

Introduce yourself to GIT Enter these lines (with appropriate changes):• git config --global user.name "John Smith" • git config --global user.email

[email protected]

You only need to do this once.

If you want to use a different name/email address for a particular project, you can change it for just that project.• cd to the project directory.• Use the above commands, but leave out the --

global

15

Page 16: Source control

Create and fill a repository cd to the project directory you want to use. Type in git init• This creates the repository (a directory named .git).• You seldom (if ever) need to look inside this directory.

Type in git add • The period at the end is part of this command!• Period means “this directory”.• This adds all your current files to the repository.

Type in git commit –m "Initial commit“• You can use a different commit message, if you like.

16

Page 17: Source control

Clone a repository from elsewhere git clone URL git clone URL mypath• These make an exact copy of the repository at the

given URL. git clone

git://github.com/rest_of_path/file.git• Github is the most popular (free) public repository.

All repositories are equal,• But you can treat some particular repository (such as

one on Github) as the “master” directory. Typically, each team member works in his/her own

repository, and “merges” with other repositories as appropriate.

17

Page 18: Source control

Making commits If you create new files and/or folders, they are not tracked

by Git unless you ask it to do so.• git add newFile1 newFolder1 newFolder2 newFile2

Committing makes a “snapshot” of everything being tracked into your repository.• A message telling what you have done is required• git commit –m “Uncrevulated the conundrum bar”• git commit

This version opens an editor for you the enter the message.

To finish, save and quit the editor. Format of the commit message.• One line containing the complete summary.• If more than one line, the second line must be blank.

18

Page 19: Source control

Choose an editorWhen you “commit,” git will require you to type in a

commit message.For longer commit messages, you will use an editor.The default editor is probably vim .To change the default editor:• git config --global core.editor

/path/to/editorYou may also want to turn on colors:• git config --global color.ui auto

19

Page 20: Source control

Typical workflow git pull remote_repository• Get changes from a remote repository and merge

them into your own repository. git status• See what Git thinks is going on.• Use this frequently!

Work on your files (remember to add any new ones). git commit –m “What I did” git push

20

Page 21: Source control

Multiple versionsInitial commit

Second commit

Third commit

Bob gets a copyFourth commit

MergeBob’s commit

21

Page 22: Source control

Developed in 2000 and 2001 (by CollabNet, Inc.) to replace CVS and its shortcomings

• Subversion is free• Subversion is open-source• Subversion operates across a network• Subversion handles any types of files,

documents, or directories• Subversion requires administrative

support

What is subversion22

Page 23: Source control

On its own, Subversion is command-line driven• UNIX:• MS-DOS:

Numerous GUIs have been built on top of SVN• TortoiseSVN• VisualSVN• XCode (Mac OS X)

Using Subversion

http://tortoisesvn.net/

23

Page 24: Source control

TortoiseSVN is• Open-source (free)• Integrated directly

into Windows Explorer• Usable with any development environment

TortoiseSVN

http://tortoisesvn.net/

24

Page 25: Source control

Open source application – download it from• http://tortoisesvn.net/downloads

After the installation a newoption appears in the menu when you right click on a folder.

25

Page 26: Source control

Checkout:• Receives a copy of an entire project from the

SVN server.• (Source files, project & make files, resource

files, etc.).

Update:• Receives copies of individual files or folders on

the server and merges them with your current copy (locally).

How to use SVN26

Page 27: Source control

Commit:• Sends an updated file (your local copy) to the SVN

server where.• It is incorporated into the original project database;

a new version number is assigned not the entire project.

Add:• Notifies SVN of a new file or folder that needs to be

added to the existing project (only if SVN is aware of a file, can you commit the file).

How to use SVN Cont.27

Page 28: Source control

Right click in the folder you want to check out into

Select SVN Checkout…

How to checkout28

Page 29: Source control

URL of repository: http://svn.cs.wayne.edu/svn/csc4111w11/

29

Page 30: Source control

Enter the user name and password:• Your accessID (xx1234) and the same

password you use for Pipeline/Blackboard

30

Page 31: Source control

• Select the project you want to download:

31

Page 32: Source control

If you have a set of files checked out and would like to update them to the most recent version of files in the repository, use the update command.

If there are newer files in the repository, they will overwrite any files you have locally, if you haven’t changed them.

TortoiseSVN can merge some files on its own, but may tell you there are conflicts with others.

If a file has a conflict use diff.

Update32

Page 33: Source control

How to update Right click on the file, folder or project you want to

update and choose SVN Update

33

Page 34: Source control

Once you have added, deleted, or changed files or directories, you can then commit those changes to the repository.

Before committing you should always update. The safest way to commit, is to diff your

project before you commit. Always check your project out after a commit

and make sure it compiles.

Commit34

Page 35: Source control

All commits need to be commented. If you forget to comment, make a trivial change

to a file and commit adding in your comment that it applies to the previous commit.

Commit Comments35

Page 36: Source control

Include:• Your Name• The type of commit (Change, Bug Fix, …)• What the commit does (Adds ToolTip dialog …)• Any other important details

Don’t include:• The names of the files (The log will have them)• The date or time

36

Page 37: Source control

How to commit Right click on the file, folder or project

you want to update and choose SVN Commit…

37

Page 38: Source control

Right click on the file you want to diff. Select Diff, this will compare your file to the

most recent (Head) version on the repository. In a new window.

How to Diff38

Page 39: Source control

If just a word changed, it will be in red on one side yellow on the other

You can use the green arrows to navigate through the differences.

Diff - How to solve conflicts39

Page 40: Source control

If lines were added/deleted one side will have gray the other yellow.

The Edit menu has options to help you combine the files.

40

Page 41: Source control

Before you commit make sure you add the file into the repository

After you add - commit

Adding new files41

Page 42: Source control

If your commit breaks the baseline. Update your local copy Check out the last good version Commit this version

If you make a bad commit42

Page 43: Source control

Carefully test your code before committing Before committing, perform an update on the whole source

code directory, and then retest Always commit only the individual files you modified, not

the entire directory When adding new files to the existing source code, always

perform SVN Add and then SVN Commit When you have conflicts, contact the teammates which

modified that file and try to solve the conflicts together to avoid damages.

Rules on using SVN43

Page 44: Source control

Do not share your login and password – you are responsible for all changes made with your ID

Do not check out projects of other groups !!! If you check in modifications to the project of other group

you might be responsible for that If you do not understand something, please ask GTA before

doing that If you do not like a client that we’re suggesting you to use,

you’re free to use any other available SVN client (but please notify me and write a couple of lines explaining why)

44

Page 45: Source control

www.powershow.com/view4/456743 OGRkM/Version_Control_using_Subversion_SVN_powerpoint_ppt_presentation.

https://www.google.com/search?q=souce+control&ie=utf-8&oe=utf-8#q=source+control+svn+ppt.

http://www.powershow.com/view1/7d30b-ZDc1Z/Version_Control_using_Subversion_SVN_powerpoint_ppt_presentation.

“Version control with git”, Jon Leoliger, O'Reilly 2009. “Pro Git”,2nd Edition, Scott Chacon, Ben Straub.

References45

Page 46: Source control