-
A snapshot saves the current state of your project or workspace on disk for possible restoration later.
-
Source control repositories keep track of individual changes to files and enable you to merge different versions of a file.
A snapshot saves the current state of your project or workspace on disk for possible restoration later.
Source control repositories keep track of individual changes to files and enable you to merge different versions of a file.
Take a Snapshot of Your Project
Why Use Source Control?
There are two fundamental reasons for using source control:
-
A source control system helps you reconstruct past versions of the software and the process used to develop it. If you are working on a project by yourself, you can commit a file to your SCM repository each time you make a major change. Then, if you find you’ve introduced bugs, you can compare the new version with a past version that worked correctly to help to locate the source of the trouble. In the worst-case scenario, you can revert to an earlier version and start over from there to reimplement the new feature. If you keep your repository, or a copy of the repository, in another, physically safe location, you can even reconstruct your project if your computer is lost or destroyed.
-
When two or more people are working on the same project, source control helps prevent conflicts and helps resolve conflicts should they arise. By keeping a central repository that holds the canonical copy of the software, the source control system allows each programmer to work on his or her own local copy without any danger of corrupting the canonical version. If you set up a system of checking out a file before working on it, you can ensure that two people are not working on the same code at the same time. If two people do change the same code, the SCM software helps you to merge the two versions. You can also look through past changes to see what they were and who made them, which can be a great help in managing the project and in fixing bugs.
Choose Git or Subversion
Xcode supports two SCM systems: Subversion
(often abbreviated svn) and Git. Subversion is always server-based and the server is normally on a remote machine, though it is possible to install one locally. Git can be used purely as a local repository, or you can install a Git server on a remote machine
to share files among team members.
To update your working copy with the latest version of the file in a remote repository, you use a pull command (in Git) or update command (in Subversion). For a local Git repository, the pull command is not needed.
Add Git or Subversion Version Control to an Existing Project
-
Use the
cdcommand to switch to your project folder, making it the current working directory. -
Enter
git initto create an empty repository. -
Enter
git add .to copy your project files into the repository. -
Enter
git commit -m "Initial commit."to commit all the files.
-
Use the
mkdircommand to create a directory with three subdirectories namedbranches,tags, andtrunkto hold a temporary copy of your project. -
Copy your Xcode project into the
trunksubdirectory. -
Use the
svnadmin createcommand to create an empty Subversion repository. -
Use the
svn importcommand to import your project into the new Subversion repository.
-
In the repositories organizer, select the appropriate Branches directory in the navigator pane and click the Add Branch button.
-
Enter a name for the new branch.
-
From the pop-up menu, choose an existing branch to serve as the starting point for this new branch.
-
If appropriate, select the option to automatically switch to the new branch.
-
Click Create.
-
In the repositories organizer, select the appropriate Branches directory in the navigator pane and click the Add Branch button.
-
Enter a name for the new branch.
-
From the pop-up menu, choose an existing branch to serve as the starting point for this new branch.
-
Enter a log message if you wish.
-
If appropriate, select the option to automatically check out the new branch.
-
Click Create.
本文介绍了如何使用快照保存项目状态,并详细阐述了源代码控制系统(如Git和Subversion)的重要性及其实现方式。通过源代码控制系统,开发者可以追踪文件的变化历史、解决多人协作时可能出现的冲突,并且能够方便地创建和管理不同版本的分支。
5018

被折叠的 条评论
为什么被折叠?



