Original: Team collaboration with GitHub
GitHub has become the cornerstone of all open source software. Developers like it, collaborate on it, and constantly develop amazing projects through it. Apart from?? Code hosting, GitHub's main attraction is using it as a collaborative development tool. In this tutorial, let's take a look at some of the most useful GitHub features, especially those that make team work more efficient, more productive, very important, and fun!
GitHub and software collaboration
One thing I think is very useful is that you can integrate GitHub's wiki into the main line of the project's source code.
This tutorial assumes that you are already familiar with the git-open source Distributed version control system, created in 2005 by the creator of Linux Linus Torvalds. If you need to modify or find out about git, please visit our previous screenshot tutorials, and some articles. In addition, you should already have an account on GitHub and do some basic functions, such as creating a repository and pushing it to GitHub. If not, you can refer to more previous tutorials.
In this world of software projects, inevitably, we have to work with a team to deliver the software. In this tutorial, we'll explore some of the tools most commonly used by software development teams. These tools include:
- Add team members -organizations and collaborators
- Pull Request – Send code changes and merges
- Error logging on issue tracking –github
- Analytics – Graphics and networking
- Project Management –trello and Pivotal Tracker
- Continuous Integration –travis CI
- Code review – code line comments vs. URL queries
- Document Records –wiki and Hubot
Prefer screenshot operation video?
If you prefer to watch screenshots, you can watch the screenshot below and use this tutorial as a side note.
Tool One: Increase team members
There are two common ways to build a team on GitHub:
- Organization – the owner of an organization can establish teams of different access rights for different code warehouses.
- Collaborators – the owner of the code warehouse can add collaborators with read-only or read-write permissions to a single warehouse.
Organization
If you oversee several teams and want to set different permission levels for each team, or add different member organizations (organizations) for different code warehouses, it will be the best option. Any GitHub user account can already create a free open source codebase for the organization. To create an organization, simply browse through your organization Settings page:
To access your organization's team pages, you can simply go to the page to http://github.com/organizations/[组织名称]/teams view it, or visit the page https://github.com/organizations/[组织名称]/teams/new to create a new team member with 3 different permission levels, such as:
-
Pull only: Extracts and merges another library or local copy. Read-only access rights.
-
Push and Pull: (1) and update the remote code warehouse. Read + Write access rights.
-
Pull, Push and manage: (1), (2), billing, setting up teams, and canceling organizational accounts. Read + Write + Administrator privileges
Co-participants
collaborators are primarily used to read and write access to the code repositories owned by individual accounts. You can https://github.com/[用户名]/[代码仓库名称]/settings/collaboration add collaborators (other github personal accounts) by adding them.
Once this is done, each partner will see a change in the access state of the code base page. With write access to the codebase, we can make a git clone, make code changes, pull and merge any changes in the remote repository with git, and eventually push the local change git to the remote code base:
Tool Two: Pull request
Pull requests are a great way to develop independently by fork a new code base and contribute the changes back to the original code base. At the end of the day, if we want, we can send a pull request to the codebase owner to merge our code changes. Pull requests themselves can generate comments among collaborators, including code quality, functionality, and even overall strategy.
Now let's explore the basic steps of a pull request.
Initiate a pull request
GitHub has two types of pull requests:
- Fork & Pull Mode – for use in public libraries, we do not have push permission.
- Shared library mode – for private code warehouses, we have push permissions. In this case it is not necessary to fork.
The following workflow is a fork-pull between two users (the original code base owner, and the fork code base owner):
-
Go to the GitHub code library where you want to contribute the changes, click "Fork" to press?? button to create a code base clone on your GitHub account:
-
This will create a copy of the code base on your own account:
-
Choose the SSH URL so that it automatically uses your own SSH key instead of asking for your user name and password every time you pull or push in Git. Next, we will clone a code base to the local computer:
$ git clone [ssh-url] [folder-name]$ cd [folder-name]
-
In general, for each new feature, we will create a new Git branch. 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 to make a very simple change to the modified Readme.md file:
$ git checkout -b [new-feature]
-
After adding a file for this new feature, we only need to commit the changes to the new branch and then switch back to the master branch:
$ git add .$ git commit -m "information added in readme"$ git checkout master
-
Here, we need to push the new branch into the remote code repository. First, we need to check the branch name of the new feature and its alias in the remote repository, and then we'll git push [git-remote-alias] [branch-name] push the 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
-
Go to the GitHub page of our fork's code base, select the branch you created for this new feature, and then click the Pull Request button:
-
After the pull request is submitted, the page jumps directly to the pull request page of the original library, and we will see the pull request we submitted as a new issue as well as a new pull request.
-
After discussion, the author of the fork's code base may want to add some new changes to the new feature. In this scenario, we need to checkout this same branch on the local computer, modify it, commit it, and push it back to GitHub. When we revisit the pull request page of the original code base, we find that the last pull request was automatically updated.
Merging a pull request
If you are the owner of the original code base, you will have two ways to merge the received pull requests.
-
merge directly on GitHub : If we want to merge directly on GitHub, we have to make sure there are no conflicts. The owner of the original library can be merged by simply clicking Merge Pull Request the button:
-
merging on the local computer : In another case, you might encounter conflicts when merging, click on the top Info icon, GitHub has very clear instructions on how to change the code from the contributor's branch to local, merge and resolve the conflict.
There are many different code branching models in the software development team. Here are two very common workflow models:
- Simple branching model and pull requests;
- A more extensive branching model.
As for what branch model to use, it depends on the team, the project, and the state at that time.
Tool Three: Error tracking
In GitHub, the center of bug tracking is the problem list (issues). Although the list of issues is primarily to track defects, we often use the following approach:
- defect : The obvious bad behavior in the software, where correction is required.
- features : Cool, great new ideas that need to be implemented.
- Pending Checklist : Checklist to be completed.
Let's explore the features of the list of issues :
-
tags : Categories with different colors to help filter problems.
-
Milestones : Date classifications that are attached to each issue can be used to determine which issues need to be resolved in the next release. Also, because each issue has milestones, it automatically updates the progress bar whenever a problem is resolved.
-
Search : A list of matching issues and milestones are automatically listed when searching.
-
allocation : Each issue can be assigned to a person who is responsible for the resolution, and this also allows us to know what we need to work on at the moment.
-
Auto Close : Contains Fixes/Fixed/Close/Closes/Closed #问题编号 the commit record that will automatically close the issue.
$ git add .$ git commit -m "corrected url. fixes #2"$ git push origin master
Obviously, we can tightly couple the task list with the code submission.
-
mentions or references : Any person included in the message text at the time of the comment #[问题编号] will automatically generate a link to the problem, making it very easy to refer to related issues during the discussion.
Tool Four: Analysis
With two tools-graphics and networking, we can gain insight into repository changes. The GitHub diagram provides a code base for collaborators, as well as a visual representation of code submissions, while the GitHub network visualization visually shows each contributor and their code submissions on all branches. These analyses and graphs are very powerful, especially when working in a team.
Figure (Graphs)
The diagram provides detailed analysis, including:
Networking (Network)
The GitHub network is a very powerful tool that allows us to see the code submissions for each contributor and how those submissions relate to other commits. As we watch the visualization of this network as a whole, we can see every library, every branch, and every commit,
Tool Five: Project management
The list of issues on GitHub can define issues and milestones, with certain project management capabilities. Some teams may prefer additional tools because of 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. Using GitHub's service hooks (hooks, we can submit code, problems, and many other activities to the task automatically.) For any software development team, this automated help not only saves time, but can also improve the update.
GitHub and Trello
Trello provides a simple and intuitive way to manage tasks. Using the Agile development approach, the Trello task card can simulate a simple, visual view of a virtual task. As an example, when a pull request is received by the GitHub code base, we will automatically generate a task card in Trello using GitHub's Hook (Hooks) service. Let's take a look at the specific steps to implement this feature:
-
First register a Trello account and create a new Trello version (Board).
-
Visit GitHub repository > Settings > Service Hooks > Trello .
-
Install Note #1obtain a token for authentication using the method described.
-
Install Note #2get the Task List ID in JSON format by giving the link. Boardid is part of the URL that we visit on our website to see the version https://trello.com/board/[BOARD-NAME]/[BOARDID] .
-
Back to GitHub's hook service, enter what we get list id and token , activate the hook, and use the Test Hook button to test whether to automatically update the viewing content each time a new pull request is received.
-
The next time you receive a new pull request, the Trello view will automatically generate a pull request task card.
GitHub and Pivotal Tracker
Pivotal Tracker is another lightweight project management tool that allows team members to respond to any changes and progress through a story-based program, making collaborative development easy. Based on the current progress of the project, a visualization chart can be generated to analyze the team's development speed, iterate the burn-up diagram, and the currently published Burn-down diagram. In the example below, we automatically deliver a story by associating a GitHub code submission (commit) to a story.
-
Create a new project on pivotal Tracker and generate a story that needs to be delivered.
-
Access Profile > API Token to copy the given API token (tokens).
-
Go back to GitHub page to access repository > Settings > Service Hooks > Pivotal Tracker , paste just copy token , activate, and save settings. This allows us to automatically deliver the corresponding story when the code is submitted.
-
When we finally commit the code revisions, we add the git commit -m "message [delivers #tracker_id]" story to the id submission record in the format.
$ git add .$ git commit -m "Github and Pivotal Tracker hooks implemented [delivers #43903595]"$ git push
-
Now, returning to the pivotal tracker page, we will find that the specified story is automatically posted and attached to the corresponding GitHub code submission link.
With Trello and pivotal tracker instances, it is clear that we are able to tightly bind our tasks and code submissions. When working as a team, this saves a lot of time and improves the accuracy of the work record. The good news is that if you've already used other project management tools, such as Asana,basecamp, or something else, you can add hooks in a similar way. If you are not currently using the project management tool hooks, self-reliance do one!
Tool Six: Continuous integration
For Team software development, continuous integration (CI) is a very important part. CI ensures that when developers commit code changes, automatic build (build) is triggered, including testing, to quickly detect errors in software integration. This will undoubtedly reduce errors in the integration process and improve the efficiency of rapid development iterations. In the following example, we will see how to use Travis CI with GitHub, automatically detect errors, and merge code after all tests have passed.
Set Travis CI
Here we use the "Hello-world" application based on the node. JS server, based on [grunt.js][http://gruntjs.com/] as the build tool, to set up the Travis CI project. Here are the files in the project:
-
hello.jsThe file is a Nodejs project. We have a destination missing a semicolon, in order for this file not to pass the Grunt build tool lint (Static Code detection Tool):
var http = require(‘http‘);http.createServer(function (req, res) { res.writeHead(200, {‘Content-Type‘: ‘text/plain‘}); res.end(‘Hello World in Node!\n‘) // 这里没有分号,将不会通过linting}).listen(1337, ‘127.0.0.1‘);console.log(‘Server running at http://127.0.0.1:1337/‘);
-
package.jsonTo define a dependent package:
{ "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" }}
-
For simplicity, the Gruntjs build tool's configuration file contains only one task (linting):
module.exports = function(grunt) { grunt.initConfig({ lint: { files: [‘hello.js‘] } }); grunt.registerTask(‘default‘, ‘lint‘); grunt.registerTask(‘travis‘, ‘lint‘);};
-
.travis.ymlIs the Travis configuration file to ensure that Travis runs our tests:
language: node_jsnode_js: - 0.8
-
Next, log in to Travis with your GitHub account and open it on the repository tab repository hook :
-
If the above steps do not trigger the build, we will have to manually configure the token to be hook duplicated in the Travis's profile column.
-
Return to the GitHub code base and use the copied token settings Travis Hook:
-
For the first time, we have to do it manually once git push to trigger the Travis build, and if everything is OK, we can access http://travis-ci.org/[用户名]/[repo名] the results of the view build.
Travis CI and pull requests
There was no previous pull request process that was continuously integrated, and the steps were about (1) submitting pull requests (2) merging (3) tests to see if they passed or failed. The pull request process with the continuous integration hooks reverses the (2) and (3) steps, and Travis CI will report to us the continuous integration results for each pull request, allowing us to know whether the pull request is good enough and quickly decide whether to merge into the main line. Now let's see how this is done:
-
Submit a pull request that comes with the build result. Travis will do everything, so that we can know before merging whether this merger is good enough.
-
If this pull request causes the build to fail, Travis will also warn you:
-
If we click on the red Warning link, the browser jumps to the Travis page and displays the details of this build.
Because of automated builds and timely notification, Travis CI is very helpful to the team, and it can greatly shorten the cycle of correcting errors. If you use another very well-known continuous integration tool, Jenkins, you can set up the hook service in similar steps.
Tool Seven: Code review
For each commit, GitHub has a clean interface for commenting, even commenting on a line of code. The ability to comment and issue comments and questions on a single line of code is important when conducting progressive code reviews. Open the check box at the top of the commit interface to display in-line comments.
Here are some of the URL patterns that help us code reviews to quickly show the difference between submissions:
-
Compare BRANCH/TAGS/SHA1: Use URL mode https://github.com/[username]/[repo-name]/compare/[starting-SHA1]...[ending-SHA1] . You can use a branch or tag name instead SHA1 .
-
remove whitespace For comparison : Adds ?w=1 the trailing URL to the comparison.
-
Diff: Adds .diff Plain text information that can be output to the back of the URL git diff . This feature is useful when writing scripts.
-
patch: Added .patch to the URL after the message can get the e-mail patch submission format git diff output information.
-
Line link : When viewing a file, click on any line number, GitHub will add one after the URL #行号 , and the row's background color yellow. This cleanly identifies a line of code files. We can also #开始行号-结束行号 specify a range by adding. Here is an example of a line link and a row range link.
Tool Eight: Documentation
In this section, we will explore two document methods:
-
Official documentation : Generate a formal project document using the GitHub wiki.
-
Informal documentation : use GitHub Hubot to archive discussions within the team, as well as the very interesting information that is automatically obtained by interacting with Hubot.
-
Mention, shortcut keys and emoticons
GitHub Wiki (wiki)
Each github code base 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 information for creating the page. In fact, the wiki also has its own version, and can copy the data to the local machine for updates, even offline access.
One thing I find very useful is the ability to integrate GitHub's wiki into the source code so that I don't have to maintain two separate git projects. To do this, I added the wiki as a git submodule to the main branch. If you are using Travis CI or any other CI, you must ensure that the build tool ignores the sub-modules of the wiki. In the CI file for Travis .travis.yml , add the following:
git: submodules: false
Then add a git submodule wiki to 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 submodule in the code base project.
GitHub Hubot
Hubot, in short, can greatly add a lot of fun records, and inform the group to discuss important submissions.
Hubot is a simple chat bot that can retrieve information or provide notifications whenever GitHub has code to submit, issue, or activity. In a team designed to reduce or even completely eliminate meetings, Hubot has a chat interface for all team members to help you document each discussion. This, of course, facilitates a flexible work sequence because the team does not need to be present at the same time. Warning: Hubot is very addictive!
With this, let's start setting up Hubot on Heroku and have chat bots with campfire chat interface! [Heroku] [] and campfire, there is a free version for everyone to start trying.
-
We will use GitHub-produced hubot to support campfire. You can also use other chat adapters, such as Skype,irc,gtalk, if you prefer.
-
Create a campfire account for Hubot only, this account will create a new room and invite others to join.
-
Based on instructions given on Hubot wiki, deploy Hubot to Heroku. If the URL of the Heroku application returns one Cannot GET / , do not panic, because no return is obtained by default.
-
From Hubot campfire account, invite your own account, now, login to your own campfire account, and then execute Hubot help , you will get all Hubot support commands.
-
Try it a few times, for example Hubot ship it or Hubot map me CERN .
-
Next, we will add a Hubot script, which already has a large number of scripts, with command instructions.
-
As an example, we will add a GitHub commit script so that each time there is a new commit, Hubot will notify everyone in the chat room. Place the file github-commits.coffee in the scripts directory.
-
Update package.json the file, adding a new dependency package according to the instructions of each script file header.
-
Use the following command to publish the code again to Heroku:git push heroku master
-
Browsing the GitHub code base, we want the code submission notification to be displayed in the chat room, add one to the code base settings web hook , and the github-commits Webhook will be[HUBOT_URL]:[PORT]/hubot/gh-commits?room=[ROOM_ID]
-
Next time when the code base has a new code submission, Hubot will say so in the chat room:
Check other github-related Hubot scripts, or if you want to write a script yourself, here's a cool tutorial! In short, Hubot can greatly add a lot of fun in documenting, notifying groups about important submissions, issues, and activities that occur in the codebase. Try it!
The last point about using GitHub with the team is that there are some productivity-boosting tips:
-
mention (Mentions) – In any text area, we can refer to @用户名 another GitHub user, and the user will be notified.
-
Shortcuts – Press SHIFT + ? to see the shortcut keys on any page on GitHub.
-
Emoji – the text area on GitHub also supports the inserted icon by using emoji. Come on, working with teammates is a bit of fun!
Collaboration with non-software projects on GitHub
Most of us would think that using GitHub can only be a software project. After all, GitHub is created for social programming. However, there are some cool libraries using github that are used for non-coding projects, and their collaborations and discussions are just as great. Because these projects are open source, anyone can contribute, it is quick to fix bugs, easily report bugs, and work effectively with like-minded people. Just for fun, here are some of them:
- House Repair: Problem tracking for houses
- Books: Little MongoDB book, Backbone Fundamentals
- Lyrics: Jsconfeu lyrics
- Looking for a boyfriend: Boyfriend_require
- Teaching: Wiki
- Genomic data: Ash dieback epidemic
- Blog: CSS Wizardry
Can you imagine what the GitHub development team thinks of these projects?
"We dig into the fun of using github like this!" ”
More Resources
- Social Coding in GitHub, a-paper by Carnegie Melon University
- How GitHub uses GitHub to build on 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 fun to cooperate!
Those are collaborative tools that have been saved on GitHub. Most are automated tools that are used as analysis tools or that save time when working with teams. Do you have more skills in GitHub team work? Let's share!
Working with GitHub for teamwork