Use GitHub for team collaboration

Source: Internet
Author: User
Tags mongodb book sha1 version control system hubot

Original article: team collaboration with GitHub

GitHub has become the cornerstone of all open source software. Developers like it, collaborate based on it, and constantly develop amazing projects through it. Except ?? Code hosting, GitHub's main attraction is to use it as a collaborative development tool. In this tutorial, let's take a look at some of the most useful GitHub functions, especially those that make the team work more efficient, more productive, and very important and fun!

GitHub and software cooperation

One thing that I think is very useful is that the GitHub wiki can be integrated into the main source code line of the project.

This tutorial assumes that you are familiar with the git-Open Source distributed version control system, which was created in 2005 by Linus Torvalds, the Linux creator. If you need to modify or find out about git, visit our previous screenshot tutorials and some articles. In addition, you should already have an account on GitHub and have done some basic functions, such as creating a repository and pushing it to GitHub. If not, refer to more previous tutorials.

In this world of software projects, it is inevitable that we must work with a team to deliver software. In this tutorial, we will explore some of the tools most commonly used by software development teams. These tools include:

  • ADD team members-Organization and creator
  • Pull request-Send code change and merge
  • Problem tracking-Error records on GitHub
  • Analysis-Graphics and networks
  • Project Management-Trello and pivotal Tracker
  • Continuous Integration-Travis Ci
  • Code Review-Code line comment and URL Query
  • Document record-Wiki and hubot
Do you prefer screenshots?

If you prefer to watch screenshots, you can watch the following screenshots and use this tutorial as a side note.

Tool 1: Add team members

There are two common methods to establish teamwork on GitHub:

  • Organization-The owner of an organization can create teams with different access permissions for different code repositories.
  • Collaborators-The code repository owner can add collaborators with read-only or read/write permissions to a single repository.
Organization

If you want to monitor several teams, set different permission levels for each team, or add different member organizations (organizations) for different code repositories, it is the best choice. Any GitHub user account can already create free open source code library organizations. To create an organization, you only need to go to your organization settings page:

To access the Organization's team page, you can simply go to the pageHttp://github.com/organizations/?organization name #/teamsTo view or access the page.Https://github.com/organizations/?organization name #/teams/newCreate a team member with three different permission levels, such:

  1. Pull only: extract and merge another database or local copy. Read-Only permission.

  2. Push and pull: (1) update remote code repository. Read + write access permission.

  3. Pull, push and management: (1), (2), billing, Team creation, and Organization account cancellation. Read + write + administrator permission

Collaborators

CollaboratorsIt is mainly used to read and write code repositories owned by a personal account. You can useHttps://github.com/?user=/#code repository name #/settings/collaborationTo add partners (Other GitHub personal accounts ).

Once this is done, each partner will see a change in the access status of the code base page. After having the write access permission to the code base, we can perform a git clone to make code changes and use git to pull and merge any changes in the remote repository, finally, git pushes local changes to the remote code library:

Tool 2: Pull request)

Pull requests are a great way to use fork as a new code library for independent development and contribute the changes back to the original code library. At the end of the day, if we want to, we can send a pull request to the code repository owner to merge our code changes. Pull requests can trigger comments between collaborators, including code quality, functions, and even overall strategies.

Now let's look at the basic steps of a pull request.

Initiate a pull request

GitHub has two pull request methods:

  1. Fork & Pull method-used in public libraries, we do not have the push permission.
  2. Shared library method-for private code repository, we have the push permission. In this case, fork is not necessary.

The following workflow is the fork-pull mode between two users (the original code base owner and the fork code base owner:

  1. Go to the GitHub code library that you want to contribute, and click "fork" to press ?? Button to create a code library clone on your GitHub account:

  2. This will create a copy of the code library in your account:

  3. Select an ssh url, which will automatically use your own SSH key, instead of asking your username and password every time you run git pull or push. Next, we will clone a code library to the local computer:

    $ git clone [ssh-url] [folder-name]$ cd [folder-name]
  4. In general, we will create a new git branch for every new feature. This is a good practice, because in the future, if we need to further update the branch after some discussion, the pull request will be automatically updated. Let's create a new branch and make a very simple change to the readme. md file:

    $ git checkout -b [new-feature]
  5. After adding a file for this new function, we only need to submit the modification to this new branch, and then switch back to the master Branch:

    $ git add .$ git commit -m "information added in readme"$ git checkout master
  6. Here, we need to push the new branch to the remote code repository. First, we need to check the branch name of this new function and its alias in the remote repository. Then we usegit push [git-remote-alias] [branch-name]Push this change.

    $ git branch* masterreadme$ git remote -vorigin  [email protected]:[forked-repo-owner-username]/[repo-name].git (fetch)origin  [email protected]:[forked-repo-owner-username]/[repo-name].git (push)$ git push origin readme
  7. Go to the GitHub page of our fork code library, select the Branch created for this new function, and then clickPull RequestButton:

  8. After submitting a pull request, the page will jump directly to the pull request page of the original database. We will see the submitted pull request as a new problem and as a new pull request.

  9. After discussion, the author of the fork code library may want to add some new changes to this new feature. In this scenario, we need to checkout the same branch on the Local Computer, modify, submit, and push it back to GitHub. When we access the pull request page of the original code library again, we will find that the last submitted pull request has been automatically updated.

Merge a pull request

If you are the owner of the original code library, you can merge the received pull requests in two ways.

  1. Merge directly on GitHub: To merge directly on GitHub, make sure there are no conflicts. The owner of the original library can clickMerge Pull RequestButton to merge:

  2. Merge on Local Computer: In another case, conflicts may occur during merge. ClickInfoGitHub provides clear instructions on how to pull code changes from the contributor's branch to local, merge and resolve conflicts.

There are many different code branch models in the software development team. There are two commonly used workflow models:

  • Simple Branch Model and pull request;
  • More extensive branch models.

What branch model is used depends on the team, project, and current status.

Tool 3: Error Tracking

In GitHub, the center of defect tracking isProblem list (issues). Although the problem list is mainly used to track defects, we often use the following methods:

  • Defects: The behavior that is apparently broken in the software, which must be corrected.
  • Function: A cool and awesome new idea to be implemented.
  • LIST TO BE COMPLETED: List of checks to be completed.

Let's discussProblem listFeatures:

  1. Tag: Has different color categories to help filter problems.

  2. Milestone: Date category appended to each issue, which can be used to determine which issues need to be addressed in the next version. In addition, because each problem has a milestone, the progress bar is automatically updated whenever a problem is resolved.

  3. Search: A list of matched problems and milestones are automatically listed during search.

  4. Allocate: Each problem can be solved by one person, which also helps us know what we need to work on.

  5. Disable automatically: IncludeFixes/fixed/Close/closes/closed # question No..

    $ git add .$ git commit -m "corrected url. fixes #2"$ git push origin master

     

    Obviously, we can closely couple the task list with code submission.

     

  6. Mentions or references: Anyone included in the message text when commenting# [Question No.]Will automatically generate a link to this issue, so that relevant issues can be easily mentioned during the discussion.

Tool 4: Analysis

There are two tools-graphics and networks, allowing us to gain insight into repository changes. The GitHub diagram provides collaborators of the code library and intuitive presentation of code submission, while the GitHub network visually displays each contributor and their code submission on all branches. These analyses and graphs are very powerful, especially when working in teams.

Figure (graphs)

The figure provides detailed analysis, including:

  • Contributor: Do you have any code to submit? How many lines of code have they added or deleted?
  • Code submission Activity: In the past year, how many weeks have these code submissions occurred?
  • Code frequency: How many lines of code are submitted at different stages of the project's lifecycle?
  • Record Card: When is code submission usually occurring every day?

Network)

GitHub network is a very powerful tool that allows us to see the code submissions of every contributor and how these submissions relate to other submissions. When we watch the visual presentation of this network as a whole, we can see every database, every branch, and every commit,

Tool 5: Project Management

GitHubProblem listYou can define problems and milestones and have certain project management capabilities. Some teams may prefer other tools because of some other features or existing workflows. In this section, we will see how we connect GitHub with other popular project management tools-trello and pivotal tracker. With the GitHub service hook (hooks, We can automatically update code submission, problems, and many other activities to the task. For any software development team, this automated help not only saves time, but also improves updates.

GitHub and trello

Trello provides a simple and intuitive way to manage tasks. With agile development, the trello task card can simulate a simple and visualized virtual task version view. As an example, when the GitHub code library receives a pull request, we will use the GitHub hook (hooks) Service to automatically generate a task card in trello. Let's take a look at the specific steps to implement this function:

  1. Register a trello account and create a new trello view Board ).

  2. Visit GitHubrepository > Settings > Service Hooks > Trello.

  3. PassInstall Note #1To obtain the token used for authentication ).

  4. PassInstall Note #2Obtain the list ID of tasks in JSON format. Boardid is part of the URL in which we visit the website to view the version.https://trello.com/board/[BOARD-NAME]/[BOARDID].

  5. Go back to the GitHub hook service and enter what we getlist idAndtokenTo activate the hook.Test HookButton to test whether to automatically update the checked content each time a new pull request is received.

  6. When a new pull request is received next time, the trello version will automatically generate a pull request Task card.

GitHub and pivotal Tracker

Pivotal tracker is another lightweight project management tool. It uses a story-based plan to allow team members to respond to any changes and progress, making it easy for collaborative development. Based on the current progress of the project, you can generate visual charts to analyze the team's development speed, iterate the burn-up diagram, and the burn-down diagram currently released. In the following example, we associate a GitHub code commit (COMMIT) to a story (story) to automatically deliver a story.

  1. Create a new project on pivotal tracker and generate a story to be delivered ).

  2. AccessProfile > API TokenTo copy the specified API token ).

  3. Return to the GitHub page for accessrepository > Settings > Service Hooks > Pivotal Tracker, Paste the copiedtoken, And save the settings. In this way, we can automatically deliver the corresponding story (story) When submitting code ).

  4. When we finally submit Code revisions, follow the formatgit commit -m "message [delivers #tracker_id]"ChangeidAdd to the submission record.

    $ git add .$ git commit -m "Github and Pivotal Tracker hooks implemented [delivers #43903595]"$ git push
  5. Now, return to the pivotal tracker page. We will find that the specified story is automatically released and the code submission link on the corresponding GitHub is attached.

Through the trello and pivotal tracker instances, it is clear that we can closely bind our tasks and code submissions. When working as a team, this will save a lot of time and improve the accuracy of work records. A good news is that if you have used other project management tools, such as Asana, Basecamp, or others, you can add hooks in a similar way. If you do not have a hook for the project management tool you are currently using, do it on your own!

Tool 6: continuous integration

Continuous integration (CI) is a very important part for Team software development. CI ensures that automatic build, including testing, is triggered when a developer submits code changes, to quickly detect software integration errors. This will undoubtedly reduce errors in the integration process and improve the efficiency of rapid development iteration. In the following example, we will see how to use Travis CI with GitHub to automatically detect errors and merge the code after all tests pass.

Set Travis Ci

Here we use the node. js-based server, and use the [grunt. js] [http://gruntjs.com/]to set up the Travis CI Project for the Development Tool's hello-world.pdf application. The following are the files in the project:

  1. hello.jsThe file is a nodejs project. To prevent this file from being able to use the lint (static code detection tool) of the grunt build tool, we wrote a semicolon for the purpose ):

    VaR HTTP = require ('http'); http. createserver (function (req, Res) {res. writehead (200, {'content-type': 'text/plain '}); Res. end ('Hello world in node! \ N') // There is no semicolon here and will not pass linting }). listen (1337, '2017. 0.0.1 '); console. log ('server running at http: // 127.0.0.1: 1337 /');
  2. package.jsonDefine dependent packages:

    {  "name": "hello-team",  "description": "A demo for github and travis ci for team collaboration",  "author": "name <[email protected]>",  "version": "0.0.1",  "devDependencies": {    "grunt": "~0.3.17"  },  "scripts": {    "test": "grunt travis --verbose"  }}
  3. For simplicity, the configuration file of the gruntjs build tool only contains one task (linting ):

    module.exports = function(grunt) {  grunt.initConfig({    lint: {      files: [‘hello.js‘]    }  });  grunt.registerTask(‘default‘, ‘lint‘);  grunt.registerTask(‘travis‘, ‘lint‘);};
  4. .travis.ymlIs the configuration file of Travis, ensure that Travis runs our test:

    language: node_jsnode_js:  - 0.8
  5. Log on to Travis with the GitHub account and gorepositoryOpen tabrepository hook:

  6. If the above steps cannot trigger the build, we will have to manually configurehookCopy the token in the profile column of Travis.

  7. Return to the GitHub code base and use the copied token to set the Travis HOOK:

  8. For the first time, we must do it manually.git pushTo trigger the Travis build. If everything is OK, we can accessHttp://travis-ci.org/# ///#repo]View the build result.

Travis Ci and pull requests (pull requests)

In the past, there was no continuous integration of the pull request process. The procedure is probably (1) Submit the pull request (2) Merge (3) test to see if it passes or fails. The pull request process with continuous integration hook will reverse (2) and (3) steps, and Travis CI will report the continuous integration results of each pull request to us, let us know if this pull request is good enough and quickly determine whether it is merged into the main line. Let's see how this works:

  1. Submit a pull request with the build result. Travis will do everything and let us know whether the merge is good enough before the merge.

  2. If this pull request causes the build to fail, Travis will also warn you:

  3. If you click the red warning link, the browser will jump to the Travis page and display the details of this build.

Because of automatic building and timely notification, Travis Ci is very helpful to the team and can greatly shorten our error correction cycle. If you use another well-known continuous integration tool Jenkins, you can use similar steps to set the hook service.

Tool 7: Code Review

For each commit, GitHub has a clean interface for commenting, or even commenting on a line of code. During the row-by-row code review, it is very important to provide comments and questions for a single line of code. Open the check box at the top of the commit interface to display comments in the row.

The following describes some URL patterns that help us review code and quickly display differences between different submissions:

  1. Comparison between branch, tags, and sha1: Use URL Modehttps://github.com/[username]/[repo-name]/compare/[starting-SHA1]...[ending-SHA1]. It can be replaced by a branch or tag name.SHA1.

  2. Remove spaces for comparison: Add?w=1To the end of the Compare URL.

  3. Diff: Add.diffAfter the URLgit diffOutput plain text information. This function is very useful when writing scripts.

  4. Patch: Add.patchAfter the URL, you can obtain the e-mail patch submission format.git diffOutput information.

  5. Line Link: When viewing the file, click any row number. GitHub will add# Row numberAnd set the background color of the row to yellow. This allows you to easily identify a line of a code file. We can also add# Start row number-end row numberTo specify a range. Here is an example of line link and line range link.

Tool 8: Documentation

In this section, we will discuss two document methods:

  1. Official documentation: Use GitHub wiki to generate a formal project document.

  2. Informal document: GitHub hubot is used to archive discussions within the team, as well as very interesting information automatically obtained through interaction with the hubot.

  3. Mentioned, shortcut keys and emojis

GitHub Wiki)

Each GitHub code library can generate a wiki, which makes it easy to store code and documents in the same repository. To create a wiki, access the Wiki tab of the Main title and set the page creation information. In fact, the Wiki also has its own version, and can copy data to a local machine for updates, or even offline access.

One thing I think is very useful is to integrate the GitHub wiki into the source code, so that I don't have to maintain two independent git projects. To do this, I add Wiki as a git sub-module to the main branch. If you are using a Travis CI or any other Ci, make sure that the build tool ignores the sub-modules of the Wiki. In the Travis CI File.travis.yml, Add the following content:

git:  submodules: false

Add a git submodule.wikiTo the main code base:

$ git submodule add [email protected]:[username]/[repo-name].wiki.gitCloning into ‘hello-team.wiki‘...remote: Counting objects: 6, done.remote: Compressing objects: 100% (3/3), done.remote: Total 6 (delta 0), reused 0 (delta 0)Receiving objects: 100% (6/6), done.$ git add .$ git commit -m "added wiki as submodule"$ git push origin master

Now, the wiki is displayed as a sub-module in the code library project.

GitHub hubot

Hubot, in short, can greatly add a lot of fun records and notify the group to discuss important submissions.

Hubot is a simple chatbot that can retrieve information or provide notifications whenever GitHub has code to submit, question, or activity. In a team designed to reduce or even completely eliminate meetings, hubot has chat interfaces for all team members, helping you record every discussion. This certainly promotes flexible work schedules because the team does not have to attend the discussion at the same time. Warning: hubot is very addictive!

With this, let's start setting up a hubot on Heroku and a chatbot with the campfire chat interface! [Heroku] [] and campfire both have free versions for your start.

  1. We will use a hubot developed by GitHub that supports campfire. If you want to, you can also use other chat adapters such as Skype, IRC, and Gtalk.

  2. Create a campfire account only for hubot. This account creates a new room and invites others to join.

  3. Based on the instructions on the hubot wiki, deploy the hubot to Heroku. If the Heroku application URL returnsCannot GET /Don't panic, because no response is returned by default.

  4. From the hubot campfire account, invite your own account. Now, log on to your own campfire account and then executeHubot help, You will get all commands supported by hubot.

  5. Try several times, suchHubot ship itOrHubot map me CERN.

  6. Next, we will add a hubot script, which contains a large number of scripts with command instructions.

  7. As an instance, we will add a GitHub submission script so that every time a new submission is made, hubot will notify you in the chat room. Change the filegithub-commits.coffeePlacescriptsDirectory.

  8. Updatepackage.jsonFile, add a new dependency package according to the instructions of each script file header.

  9. Run the following command to release the code to Heroku again:git push heroku master

  10. Browse the GitHub code library. We hope that the Code submission notification will be displayed in the chat room. Addweb hookgithub-commitsScript, webhook will be[HUBOT_URL]:[PORT]/hubot/gh-commits?room=[ROOM_ID]

  11. Next time when the code library has a new code commit, hubot will say this in the chat room:

Check other GitHub-related hubot scripts, or if you want to write a script yourself, here is a cool tutorial! In short, hubot can greatly add a lot of fun in documenting and notifying groups about important submissions, issues, and activities in the code library. Try it!

To use GitHub with the team, we should note that there are some productivity improvement skills:

  1. Mentioned (mentions)-In any text area, we can use@ UsernameMention another GitHub user and the user will be notified.

  2. Shortcut Key-PressSHIFT + ?You can view the shortcut keys on any GitHub page.

  3. Emojis-Using emojis, the text area on GitHub also supports inserted icons. Come on, it's fun to work with teammates!

Cooperation on non-software projects on GitHub

Most of us will think that GitHub can only be used for software projects. After all, GitHub was developed for social programming. However, some cool libraries that use GitHub are used for non-coding projects, and their cooperation and discussion are equally great. Because these projects are open-source and can be contributed by anyone, this is a quick fix for errors, easy to report errors, and effective cooperation with like-minded people. For fun, here are some of them:

  • House Repair: tracking of House Problems
  • Books: Little MongoDB book, backbone fundamentals
  • Lyrics: jsconfeu lyrics
  • Find a boyfriend: boyfriend_require
  • Tutorial: Wiki
  • Genome data: ash dieback epidemic
  • Blog: CSS wizardry

How do you think of these projects by the GitHub development team?

"Let's explore the fun of using GitHub like this !"

More resources
  • Social coding in GitHub, a research paper by Carnegie Melon University
  • How GitHub uses GitHub to build GitHub by Zac Holman
  • Git and GitHub secrets by Zac Holman
  • New features in GitHub from the GitHub blog
  • GitHub help: Pull requests, fork a repo
  • GitHub features for collaboration
  • Nettuts + Tutorials: git and GitHub
  • Lord of the files: How GitHub tamed free software (and more) by wired
More cooperation fun!

These are all collaborative tools accumulated on GitHub. Most of them are used as analysis tools or automated tools to save time when working with teams. Do you have more skills for GitHub team collaboration? Let's share it with you!

Use GitHub for team collaboration

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.