Git Management of App development process source code and git Management of app process source code
The base project can be compiled and run, but there is no actual function. Before continuing to improve the base project, we need to consider code management.
Whether it is development by one person or development by a team, Version Management of source code is required. Anyone can manage any operations on the Code. Is there not enough reason.
I have used SVN before, but the best experience is Git.
1. The local repository is easy to use and can be used completely away from the remote repository.
2. All trunk and branches are managed in a unified manner and can be switched freely.
3. easy and pleasant code Merging
Xcode comes with code Git management, which was mentioned during project creation. It was not recommended to use it at that time because other management tools were ready for use. If Xcode's git management is used during project creation, you can modify it in the following two ways:
Method 1:
1. Open the terminal and enter the command: defaults write com. apple. finder AppleShowAllFiles-bool true (false indicates that hidden files are not displayed)
2. Delete the hidden file. git under the root directory of the project.
3. Use the new management software for git Management
Method 2:
Copy the files and folders visible in the root directory to the new root folder to manage the version of the root folder.
Source code Git Management Configuration
Management Solution: Github + SourceTree
1. Go to https://github.com and register an account
2. Download the git client. Github also provides a client that directly uses the account and password to log on to and manage projects: https://shorttop.github.com /. I will not discuss it. I am still using SourceTree to manage other projects, so I will continue to use SourceTree here.
In git mode, SSH keys are mostly involved, and the generation process is simply recorded.
Note: The github client uses the account and password to verify the user's identity and manage its own projects. The SSH key simplifies the process of entering the account and password. After adding the SSH key to the github account, the devices authorized by github to generate the SSH key can use the git management tool to manage github projects.
SSH key generation and setting process:
1. Go to the (shift + command + G) folder "~ /. Ssh"
If the xxxx. pub file exists, it is the target file. Open it in a text editor and copy all the content.
Find the location for adding an SSH key to github as shown in the following figure:
For example, click icon-> settings on the far right of the logon page to enter the settings page.
For example, select the SSH and GPG keys columns, click the "New SSH key" button, the title is used to describe, the SSH key copied on the key column is copied, and then click "Add SSH key.
2. If the above file does not exist. Open the terminal, enter: ssh-keygen-t rsa-C "xxxx@xxxx.com", then press enter and follow the prompts to complete the operation. "Xxxx@xxxx.com" is recommended for github account mailbox
After generation, follow step 1.
After completing the preceding operations, you can use SourceTree.
Here, we can choose to set a remote account in SourceTree, generate a local repository based on the base project, and then create a remote repository based on the local repository. Alternatively, you can create a repository named "base" on Github without setting an account. Then, use ssh to clone the repository to your local computer and move the project file to the repository. I used the latter.
Create a repository
1. Click the plus button in the upper right corner, as shown in figure-> new repository, the following page appears:
Description: Enter the repository name and optional description. The type is public by default. If you want to set it to private type, you need to pay. Here, provides another git repository platform Gitlab (Address: https://about.gitlab.com/) that allows you to create private repositories for free, similar to Github.
You can also check to add a README file and A. gitignore file. The former allows you to clone the repository to a local directory immediately. By default, the files are not displayed and the files or types that are not managed by the git repository are recorded. There is no need to add a license for the moment.
2. After the creation is successful, the page is shown as follows:
We recommend that you clone the file by using SSH authentication. Click clone or download to copy the string: xxxxxxx/base. git.
3. Open the locally installed Sourcetree and click "+ new repository"-> clone from url. The following page is displayed:
Use the copy string as the source URL. The target path and name are automatically entered.
I put the project created by Xcode and the project cloned by SourceTree in the same folder. to differentiate, I renamed the cloned root directory as "githubbase ".
After cloning, copy the base project to the githubbase directory.
After opening the local repository, you can see the files that are not saved.
The usage of SourceTree is recorded as follows:
1. Check the unsaved files option to add the list of files that have not been saved to the file to be submitted.
2. Click Submit in the upper left corner to submit the modification to the local repository.
3. The push button is submitted to the remote repository.
4. The "pull" button is the latest code synchronized to the remote warehouse.
5. You can right-click to save the file and "Ignore" this file or this type, such as. xcworkspacedata.
6. Click the "branch" button to create a new branch. Right-click the branch or main version to switch to the current editing branch.
7. Right-click the branch that is not edited and can be merged into the current branch.
8. Right-click a file to view the modification log.
9. External tools can be used to resolve conflicts
10. In the menu bar SourceTree-> preference settings-> General, you can set the full name and email address when submitting code as the identity
11. Even if you have set a general identity, you can also set a separate ID for each repository.
Set in the upper-right corner-> advanced, you can set the user information of the current Warehouse
More detailed functions and operations are not recorded one by one.
At this point, the source code has been managed.
Source code: https://github.com/ALongWay/base