How to host your project to GitHub
iOS Development outreach-How to host your project to GitHub
Description: This article focuses on how to host an OC project to GitHub and re-operate the light theory.
First step: Register a GitHub account first, which is required
Registered Address: GitHub website Registration Portal
Step two: Prepare for work
The GitHub Web site uses git versioning tools to manage warehouses, noting that they are not equivalent.
GitHub is the world's largest repository of third-party open source repositories, and Git is a distributed version Management control tool (in addition to git, there are other versioning control tools such as SVN).
Basic introduction to Git and basic use here will not do more introduction, if necessary, please refer to: Git tutorial.
Related books about git usage:git Versioning (2nd edition) | git authoritative Guide ( electronic version )
The introduction and instructions for GitHub can be found in the book GitHub Primer and Practice (some of the content is not available in the electronic version of the download) or directly through the official website of the help page to view.
Step three: Build an empty warehouse on GitHub (repositories)
We assume that you already have a GitHub account and that you are logged in successfully, then you will be able to find an interface like the one below.
The following is a brief description:
The 1th area will display your personal information, such as nicknames, Avatars, contact details, etc.
The 2nd area shows some of the relevant third-party libraries.
The 3rd area shows your activity on the GitHub website, which is represented by a variety of squares, one of which represents one day (life is plainly a little more than 30,000 small squares, and there are a few useless things to be counted here), the darker the color, the higher the activity.
The 4th area can do some configuration operation and so on.
After seeing this interface, click on the arrow to refer to the +, select the new repositories option will jump to the following interface, simple configuration can create an empty warehouse.
In the use of red line in the place to be aware of, in the creation of the warehouse needs to be simple configuration of the warehouse, such as the warehouse name and so on.
Where repositories name needs to be filled in is the name of the warehouse.
Description (optional) to fill out a simple description of the warehouse, mainly to introduce the functions of the warehouse (of course, if the lazy can not write).
The next two options (public|private) indicate whether the warehouse you are creating is public or private. What is the difference between public and private? If the warehouse is public then it means that anyone can unconditionally get the content of your entire warehouse, free of charge. If the warehouse is private, then others cannot access your private warehouse, the condition is to pay the protection fee, protection fee is not expensive monthly 7$ only. Here I only do demo select Public Warehouse can.
Initialize this repository with a readme indicates whether a Readme file is generated when the repository is initialized. When we look at other people's framework, we will have a description of the framework version information, how to use it, and so on, which is the Readme file, which is selected on the page.
Add. Gitignore button, a drop-down box appears and asks if you want to set the Ignore file for the repository. This depends on your own needs, usually if your warehouse and code project is related, it is best to choose the appropriate ignore files (such as OC Project can choose Object-c,swift Project can choose Swift), as for why please refer to the basic use of git.
ADD a license button, the click will appear a drop-down box, you need to choose an open source protocol, open source agreement there are many kinds of use of more than MIT or Apache, different open source agreement on the use of the project and other different provisions, details can refer to choose an open SOURCE License.
Once the above information is set up, then just click the Create Respository button to create an empty warehouse.
Fourth Step: Understanding the main warehouse interface
At this point, an empty warehouse has been created and you will see the following interface.
Here is a brief introduction to the warehouse page information.
The 1th area is the name of the warehouse, which can be found by searching the warehouse name after you create the warehouse.
The 2nd area is a warehouse-related information, such as the Code option lists the contents of the warehouse (file), the issues option lists other people's questions about the warehouse, and the Pull request option provides a portal for other developers to request a merge when maintaining the warehouse. The setting option lists some operations that can be performed on the warehouse, such as deletions, and so on.
The 3rd area lists the number of times the warehouse was submitted, the tag version, and so on.
The 4th area lists the contents of the warehouse, and there are only three files in the current warehouse, respectively. Gitignore ignores files, license open source protocols, and initializes the generated readme files. There is a clone or download button in the upper right corner of the area, click the Download Zip button to download the repository locally.
The 5th area shows the contents of the Readme.md file.
The 6th area lists how many people are concerned about the warehouse, the popularity of the warehouse, and the number of times it was forked. We see whether a framework is popular by looking at the number of star in the warehouse and the number of times it is forked.
The above is a simple introduction to GitHub automatically generated a blank warehouse, with this blank warehouse before we can do the following.
Fifth step: Connect to the remote repository
There are many ways to connect to a remote repository, you can use a third-party git management graphical interface tool such as Sourcetree, or you can use a terminal (command line), or Xcode. Here, you choose to use Xcode to do the work.
Open the Mac above Xcode and open the upper left corner menu and select the Xcode->preference option as shown in:
Go to the Configuration information window for Xcode.
To switch to the Accounts menu, click the + sign in the lower left corner and select Add Respository. The following interface appears and needs to be configured.
Address needs to enter the remote warehouse addresses to connect, in fact, there are two ways to connect to the remote warehouse can choose one is HTTPS request, one is SSH key pair. Here, we first explain how HTTPS requests should be handled, how to obtain the warehouse address? Select clone with HTTPS after copying the address in the output box as shown in:
Type: means that you can choose Git and svn in the version management mode you use, only git (because GitHub only supports GIT management)
Authentication: means authentication is authenticated, GitHub provides two authentication methods, HTTPS and SSH, we are currently choosing HTTPS, so here we choose User Name and Password.
User name and password two are populated with the username and password of the GitHub website login.
After the configuration is complete, click the Add button and the following window appears, indicating that the connection to the warehouse was successful.
Sixth step: Download the remote repository to the local
After connecting to the remote repository, we then download the remote repository locally and select the source Control->check out of the menu bar.
The following screen will pop up to find the repository to download (usually at the end), click Next
After clicking on the Next button, you will need to select the storage location after the repository is downloaded and click Finsh to finish. Once the repository has been downloaded, you can find a. git hidden file, the Git repository, inside.
Add: You can enter the following command in the terminal to display or not show hidden files
# Show hidden files $ defaults write Com.apple.finder appleshowallfiles Yes && killall Finder
# do not show hidden files $ defaults write Com.apple.finder appleshowallfiles no && killall finder
Seventh step: Add OC Items to the repository and push to the remote server
1) First create a new project, assuming that test, the project is created after saving to the warehouse path (and. git file sibling) as
2) Open the project, you will find in the project's navigation bar each file will show different status as? M et cetera, by initializing the project in this way, the project itself has been incorporated into the management of the Git repository.
3) Submit the changes locally and push to the remote server.
Xcode itself is well integrated with Git, and clicking on the Source Control option above the menu bar can see the following view:
Where check out is equivalent to the clone directive in the git command line to download the remote repository locally.
Commit is equivalent to the commit instruction (no difference) in the git command line to commit the changes to the local git repository.
Push is equivalent to the push instruction (no difference) in the git command line, which is used to commit the changes to the remote Git repository.
The pull instruction is equivalent to the fetch instruction (no difference) in the git command line to get the latest remote repository information.
Here, we need to select the Commit option first to commit the changes to the local repository. After selecting Commit, the following interface appears:
Where the 1th region represents the content to be submitted, the 2nd region input the description of the submission (note), the 3rd area can be selected on the tick, if it is ticked, then when the bottom right button is clicked, all the changes will be submitted to the local Git repository, and then push the changes to the remote Git repository.
After you click Submit, you can refresh the home page of the repository on GitHub, which shows a new update, and the project submission is complete. Click to view the project file as shown in.
Eighth step: Command Line Operations
None of the above shows a command line, so how do you handle additions, deletions, commits, and so on, without using Xcode instead of using the command line?
1) to create a new file, you need to submit the created file to the local git repository.
Open the terminal, CD into the warehouse path, and then create a NewFile file, as shown in:
After the new NewFile file is created, the file is not managed by the GIT repository by default (it can be viewed using the git status command), and you need to add the specified file to the GIT block before committing to Git's repository, as shown in the Add command.
$ ls-l Displays the file under the current directory as a list (the NewFile file is just created)
$ git Status View git repository file status (the NewFile file status is red, indicating that it is not managed by git)
$ git Add NewFile Add the NewFile file to the Git hold (if you need to commit multiple files at once, you can use git Add. command)
$ git status re-view status (at this point the NewFile file status is green, indicating that the change has been submitted to the suspend zone)
$ git commit-m "created NewFile file" NewFile indicates that changes to the NewFile file in the deferred zone are submitted to the local Git repository (if you want to commit all changes at once, you can simply omit the specific file)
2) Submit the file to a remote (github) repository
Description: Use the git push command to push local changes to the remote repository.
At this point, refresh the home page of the repository on the GitHub site to find that the NewFile file has been submitted.
3) Modify the file and submit the modification to the remote repository.
Suppose we modify the NewFile file and then commit the changes to the Git suspend zone, commit to the local git repository, and then push to the remote repository.
Nineth Step: Other actions (Tag tag)
If your project has already completed milestone development, then you can be sure of a new version, such as a release to the official 1.0 version, and the subsequent release of 1.1.0 or version 2.0, and so on, how to use a GitHub managed project to determine a new version? Or how to tag the tag.
If the warehouse does not publish a specific version, the release is displayed as 0.
Assuming that the current project has been developed in phases and needs to be formally identified as the Test1.0 version, what should be done?
Hosting to GitHub