Collaborative development, replication projects, contribution codes in Git@osc

Source: Internet
Author: User

git @osc allows us to host code and version control, like SVN and other similar platforms, can help us achieve team collaboration development, whether you are a project team member. This tutorial is fully applicable to GitHub

1. Concept

Collaborative development: As the name implies, a project is developed jointly by multiple project members.

Fork:github offers a very handy feature that allows you to copy other people's items to your account with one click.

Pull request: A way for non-project members to contribute code.

2. [email protected] How to collaborate on development

By the project creator to enter the specified project, click "Settings" on the menu bar, you will see the following screen

Then click on "Add Member"

In the user bar, enter the member name, this block I always feel a bit strange, the afternoon colleague just registered a git account, and then I tried here a variety of ways how also search not to specify the user, probably after 2 hours, there is a magical can search, I suspect [email protected] Do you have a backstage deal? Or is there a valid time after account registration? Anyway, in this input to find the user name can, for example: I want to add a "Yang Xiao Yang" classmate, input "Yang Xiao Yang" is not found, but enter his account mailbox "Yangshuangjun" can be found, as of now, I still do not know the number of users of this search.

When a member is found, assign a role, an administrator, a developer

The differences between the two roles are described here: http://git.oschina.net/oschina/git-osc/wikis/%E5%B8%AE%E5%8A%A9

After OK, click Add User to

The project member then modifies and submits the code through the Egit client Direct clone project, enabling collaborative development.

3. [Email protected] fork function

What is the use of fork?

When you are interested in a public open source project, you can easily copy the project to your account by using the fork function to learn or contribute to the code.

First find the project you want, such as:

Click the fork button in the top right corner to confirm that the item will run to your name. It means that you have a fork in the project, which is equivalent to the inheritance in OO.

At this point, use Egit to import the project into the Eclipse project, then you can modify the code and then commit and push to update it, just like your own project.


4. [Email protected] Request function

When do I use pull reques?

Using pull request presupposes that you fork someone else's code and modify it. When you modify the code and commit, you can only push to the project under your account, and the original project will not be changed. At this point, if you want to contribute your code to the original project, then you need to use the pull request operation.

See: Click here to create a pull request

After clicking, see:

Here is nothing more than the code you submit (contribution) to do a detailed description, so that the original author fully understand the purpose of your submission.

After writing, click "Submit Pull Request", as of now, you have finished the pull request creation work;

At this point, the original project will receive a pull request application, where there will be a display

Since I have no actual request here, it shows 0, if any, click Pull requests

Detailed information is then displayed on the interface, including the title of the pull request, a detailed description, and the detailed code.

In this interface, the administrator can choose "Accept pull Request", if you choose to accept, then the code you submitted will be automatically merged into the original project, also completed your contribution.

5. After fork synchronization original author modified

When you fork a project, if the original author updates the code, then your project is definitely not automatically updated. So how do you synchronize the project with the original project? The simple way of course is to clone a copy again, but this will lose you to the code modification.

At this point, you need to manually synchronize the original project.

First enter the local library of the project to clone your fork

In order to synchronize with the original project, you first need to fetch the original item locally.

Git remote add Origin https://github.com/xxx/xxx.git #别名origin, point to the original project Git fetch Origin master #fetch orginal below the master branch

The git fetch command does not automatically merge.

Then compare the differences between the local master branch and the Origin/master branch, and then decide whether to merge. You can merge using the merge command.

git merge Origin/master #将原项目和主项目合并

Of course, we can also use the pull command without a fetch command, except that the pull command automatically merges

Git pull Origin Master

The get pull command is actually the equivalent of git fetch and git merge

Git fetch is a bit more secure in real-world use. because before the merge, we can review the update and then decide whether to merge.

After merging, use the git push command to commit.

When you first push, you may get the permission denied error prompt above because you did not add a public key for your project.

Next we add one for this machine.



Copy the contents of the id_rsa.pub, go to the Project homepage, click the "Admin" button, select "Deploy Key", click "Add Deploy Key", paste the copied content inside,

Once you've added public key, you can push now.

Concluding remarks

using [email protected] can effectively help us achieve collaborative development. Team members can submit code directly through authorization, non-team members can fork others ' projects, can use pull request to contribute code, and when the fork's original project has an update, you can also manually synchronize the project.

References

[1] Kay [email protected] The use of team development, fork, and pull request. http://my.oschina.net/kzhou/blog/150290

[2] Gevin.github how to stay in sync with the source project after you fork someone else's project. http://gevin.me/370.html

[email protected] collaborate to develop, copy projects, contribute code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.