source control
TRANSCRIPT
Content Version control Advantages & disadvantages of GIT GIT basics Subversion TortoiseSVN How to use SVN Rules on using SVN
2
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
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
Local Version Control5
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
Centralized Version Control7
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
Distributed Version Control9
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
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
GIT Basics Storing data as changes to a base
version of each file.
12
Storing data as snapshots of the project over time.
13
Working directory,staging area, and Git directory.
14
Introduce yourself to GIT Enter these lines (with appropriate changes):• git config --global user.name "John Smith" • git config --global user.email
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
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
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
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
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
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
Multiple versionsInitial commit
Second commit
Third commit
Bob gets a copyFourth commit
MergeBob’s commit
21
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
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
TortoiseSVN is• Open-source (free)• Integrated directly
into Windows Explorer• Usable with any development environment
TortoiseSVN
http://tortoisesvn.net/
24
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
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
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
Right click in the folder you want to check out into
Select SVN Checkout…
How to checkout28
URL of repository: http://svn.cs.wayne.edu/svn/csc4111w11/
29
Enter the user name and password:• Your accessID (xx1234) and the same
password you use for Pipeline/Blackboard
30
• Select the project you want to download:
31
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
How to update Right click on the file, folder or project you want to
update and choose SVN Update
33
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
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
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
How to commit Right click on the file, folder or project
you want to update and choose SVN Commit…
37
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
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
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
Before you commit make sure you add the file into the repository
After you add - commit
Adding new files41
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
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
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
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