svn for mac
来源:互联网 发布:单片机蓝牙模块程序 编辑:程序博客网 时间:2024/06/09 20:59
Subversion WithMac OS X Tutorial
Tags:
Posted 21. September 2006.
Updated: April 2011
Subversion is a version control system that allows you to work withother people on a project and switch back easily to every versionever made. It can be used for all kinds of projects likeapplication source code, web sites, even images or just simple textdocuments. Once you have it all set up and followed all the stepsdescribed below, it is easy to handle and a very useful thing – notjust for computer geeks.
About This Tutorial
Thistutorial explains the basics from
The Concept of Subversion
Subversion works by setting up a central repository on a server orlocal computer that every user connects to and downloads a personalworking copy from. When changes are made to the working copy, theycan be uploaded to the repository. If these changes conflict withchanges other people may have uploaded since the last time youupdated your working copy, subversion tries to merge these filesand solve the conflicts.
Downloading and Installing Subversion
I recommend downloading the Subversion Mac OS X packagefrom
Download and run the installer. Note that Subversion itself doesn'tfeature a graphical user interface, so you won't find any new filesin your application directory after installation. Instead itinstalls some command line commands into thedirectory/opt/subversion/bin*
To be able to call the Subversion commands from every directory,you must add it to your path. If you don't know what that means,don't worry. Just follow the instructions.
Open the Terminal application. It can be found in the/Applications/Utilities folder. Whenever you see below a linestarting with a dollar sign, you should type the text after thedollar sign in your terminal and hit return.
Start by creating a new text file called '.bash_profile', i.e. withthe command line text editor pico:
Add the following line to the text file:
Now hit Control-X, then confirm saving the file with 'y', followedby return.
You have just added Subversions's location to your path. LetTerminal read this file to know the path has changed (there's anempty space between the dots):
Creating a Sample Subversion Project
First we will need to set up a Subversion repository on our localcomputer. That is the place to store all versions of our project.Now create your repository like this:
This will create a repository named 'SVNrep' in your your homedirectory, although svnadmin won't give you any feedback. If youdon't trust me on this, you can check the existence of this folderby typing 'ls' in the terminal or looking for it in the Finder.
Next we create our sample project. Create a new folder and an emptyfile named 'test.txt' inside this folder:
$ touch test/test.txt
Let's import this project into the repository. Type in yourterminal, by replacing 'sara' with your own user name:
This will output:
Committed revision 1.
We have just imported the folder 'test' into the repository'SVNrep'. Each version in the repository is called a "revision" andis identified by a unique number. Always provide a short message('-m') of the changes you made to the repository like we justdid!
Retrieving Files From Subversion
Now we get a copy to work on from the repository. This process iscalled "check out":
The output will show all files added ('A') to our working copy:
Checked out revision 1.
Change into the working copy directory by typing:
Next check the content of our working copy in the terminal:
This will output the directory including hidden files:
....svntest.txt
Note the hidden directory '.svn'. This holds some subversion infolike the name of the repository, so you don't have to type that inthe future. If you would like a copy of your repository withoutthis hidden directory in every folder, you have to export acopy:
$ svn export file:///Users/your_user_name/SVNrep/test test-copy
This copy is now safe to deploy on the web. It is not a workingcopy though, so you can't commit changes back to the repositoryfrom this folder.
Time For Changes
It is time to make some changes to our file and save it back to therepository. Open 'test.txt' from the working copy with yourfavourite text editor and type "Hello world" or whatever you are upto, then save the file.
You can then query Subversion to find out the differences betweenthe repository and your copy:
This will state that our file has been modified ('M'):
Now we want to update the repository with the changes we made. Thisprocess is called "committing":
This will output:
Transmitting file data .
Committed revision 2.
Dealing With All These Versions
Let's assume, that someone else working on your project madechanges to the repository. You will want to update your localworking copy to incorporate the changes:
Because in our example nobody else made changes to the repository,this will do nothing and output:
To list all revisions in the repository, type:
This will output a list of all revisions with it's messages:
r2 | sara | 2006-10-08 16:41:46 +0200 (Sun, 08 Oct 2006) | 1line
Added some text
------------------------------------------------------------------------
r1 | sara | 2006-10-08 16:10:36 +0200 (Sun, 08 Oct 2006) | 1line
Initial import
------------------------------------------------------------------------
If you would like to see the exact differing lines to a specificrevision, i.e. revision 1, just type:
The output states that the line "Hello world" has been added("+"):
--- test.txt (revision 1)
+++ test.txt (working copy)
@@ -0,0 +1 @@
+Hello world
Maybe you would then rather like to switch back to an olderrevision:
This will update ('U') your copy back to revision 1 and output:
Updated to revision 1.
Note that all commands are used on the whole current workingdirectory. You could also provide a single filename for each ofthese commands, i.e. 'svn update test.txt'.
Renaming, Adding And Deleting Files From The Repository
Sometimes you may add new files to your working copy.
They will not be included in the repository though, unless youmanually add them to the repository:
$ svn commit -m "added new file"
If you later would like to remove a file from the repository, typelikewise:
$ svn commit -m "deleted file"
Note that you should never delete or rename files from your workingcopy without Subversion knowing. You can modify inside your filesas much as you like. But if you just rename files or move them toanother folder, Subversion will loose track of them. Always use'svn' commands for those operations.
This is how you move a file accordingly:
$ svn commit -m "moved file"
All of these commands will not only affect the repository, but yourworking copy as well. So you should never have to delete or renamea file with your Finder.
If you are working alone on a project, this is it! Well, basicly.The next chapter will explain dealing with multiple users.
Working With Other People
To act as if someone else was working on your project, you couldnow check out a second working copy named i.e. 'test-copy2' intoyour home directory and make some more changes to it. Then commitit to the repository following the steps from above.
Now think of a possible conflict: two people have downloaded theirworking copy and started working on the same file. When Saracommits her files before Michael does, Michael will get an errormessage when committing because his copy is not up to date anymore:
Sending test.txt
svn: Commit failed (details follow):
svn: Out of date: '/test/test.txt' in transaction '3-1'
Michael will then first have to update his working copy by typing'svn update'. This will merge Sara's earlier changes into Michael'sworking copy, line by line.
Michael can now commit the merged copy to the repository. In somerare cases however, there my be a conflict that Subversion cannotsolve itself. It will then create three files in Michael's workingcopy:
test.txt.r2
test.txt.r3
Michael now has to manually put the pieces together in the file'test.txt', deciding which changes to keep. Only when this is madeand the three extra files are deleted, Subversion will allowMichael to commit his files.
Now go play around with it to get used to it. Of course there ismore to Subversion. You could type "svn help" in the terminal tolist all commands or read the freely available SVNbookat
Graphical User Interfaces
Many people don't like working with the terminal. They find itcomplicated to remember the text commands, as opposed to clickingon buttons in applications. There is a couple of free or commercialapps available on the internet, that provide a graphical userinterface for Subversion commands. I think it's best practice tolearn Subversion from the terminal first, before you use agraphical client, to understand the way subversion worksbetter.
A nice and free GUI for Mac OS X is
- svn for mac
- SQLiteManager for Mac Or Windows
- Virtualbox for Mac 的使用
- Java for Mac OS X Lion
- MAC环境下 svn的使用
- svn客户端 authorization failed
- software engineering for SaaS - …
- Two life , for one thing
- 查找 MAC 地址
- Install ssh for AIX
- Custom TabBar for iOS
- subversion for windows 安装
- Solution for "Waiting for …
- dnw for linux
- Python For S60
- BT for linux
- FFMPEG for Iphone
- Code for SE
- android引入第三方jar包时报错java…
- android用https发送post请求
- android2.2系统自带drawable资源
- Android系统设置
- 【android】scaleType属性与ImagVi…
- svn for mac
- Mac朗读中文
- adb无线网络调试
- 执子之手,与子偕老 -- 仓央嘉措
- Android抽象布局——include、merge 、ViewStub
- android fragment
- 优秀Android开发博客和网站大全
- android添加常驻图标到状态栏
- windwos键盘的过滤(Hook键盘中断反过滤与利用IOAPIC重定位修改处理函数)