From 482d18e313bda155eff178d1fb61d23f53fabee3 Mon Sep 17 00:00:00 2001 From: wolfg1969 Date: Mon, 28 Apr 2014 18:21:30 +0800 Subject: [PATCH 1/4] start zh-cn translation --- README.zh-cn.md | 761 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 761 insertions(+) create mode 100644 README.zh-cn.md diff --git a/README.zh-cn.md b/README.zh-cn.md new file mode 100644 index 0000000..89a47e8 --- /dev/null +++ b/README.zh-cn.md @@ -0,0 +1,761 @@ +# GitHub Cheat Sheet +A collection of cool hidden and not so hidden features of Git and GitHub. This cheat sheet was inspired by [Zach Holman](https://github.com/holman)'s [Git and GitHub Secrets](http://www.confreaks.com/videos/1229-aloharuby2012-git-and-github-secrets) talk at Aloha Ruby Conference 2012 ([slides](https://speakerdeck.com/holman/git-and-github-secrets)) and his [More Git and GitHub Secrets](https://vimeo.com/72955426) talk at WDCNZ 2013 ([slides](https://speakerdeck.com/holman/more-git-and-github-secrets)). + +*Read this in other languages: [English](README.md), [한국어](README.ko.md), [日本語](README.ja.md).* + +## Table of Contents + - [GitHub](#github) + - [Ignore Whitespace](#ignore-whitespace) + - [Adjust Tab Space](#adjust-tab-space) + - [Commit History by Author](#commit-history-by-author) + - [Cloning a Repository](#cloning-a-repository) + - [Comparing Branches](#comparing-branches) + - [Compare Branches across Forked Repositories](#compare-branches-across-forked-repositories) + - [Gists](#gists) + - [Git.io](#gitio) + - [Keyboard Shortcuts](#keyboard-shortcuts) + - [Line Highlighting in Repositories](#line-highlighting-in-repositories) + - [Closing Issues via Commit Messages](#closing-issues-via-commit-messages) + - [Cross-Link Issues](#cross-link-issues) + - [CI Status on Pull Requests](#ci-status-on-pull-requests) + - [Syntax Highlighting in Markdown Files](#syntax-highlighting-in-markdown-files) + - [Emojis](#emojis) + - [Images/GIFs](#imagesgifs) + - [Embedding Images in GitHub Wiki](#embedding-images-in-github-wiki) + - [Quick Quoting](#quick-quoting) + - [Quick Licensing](#quick-licensing) + - [Task Lists](#task-lists) + - [Relative Links](#relative-links) + - [Metadata and Plugin Support for GitHub Pages](#metadata-and-plugin-support-for-github-pages) + - [Viewing YAML Metadata in your Documents](#viewing-yaml-metadata-in-your-documents) + - [Rendering Tabular Data](#rendering-tabular-data) + - [Diffs](#diffs) + - [Rendered prose Diffs](#rendered-prose-diffs) + - [Diffable Maps](#diffable-maps) + - [Expanding Context in Diffs](#expanding-context-in-diffs) + - [Diff or Patch of Pull Request](#diff-or-patch-of-pull-request) + - [Hub](#hub) + - [Decreasing Contributor Friction](#decreasing-contributor-friction) + - [Contributing Guidelines](#contributing-guidelines) + - [GitHub Resources](#github-resources) + - [GitHub Talks](#github-talks) + - [Git](#git) + - [Previous Branch](#previous-branch) + - [Stripspace](#stripspace) + - [Checking out Pull Requests](#checking-out-pull-requests) + - [Empty Commits :trollface:](#empty-commits-trollface) + - [Styled Git Status](#styled-git-status) + - [Styled Git Log](#styled-git-log) + - [Git Query](#git-query) + - [Merged Branches](#merged-branches) + - [Web Server for Browsing Local Repositories](#web-server-for-browsing-local-repositories) + - [Git Configurations](#git-configurations) + - [Aliases](#aliases) + - [Auto-Correct](#auto-correct) + - [Color](#color) + - [Git Resources](#git-resources) + - [Git Books](#git-books) + +## GitHub +### Ignore Whitespace +Adding `?w=1` to any diff URL will remove any changes only in whitespace, enabling you to see only that code that has changed. + +![Diff without whitespace](https://camo.githubusercontent.com/797184940defadec00393e6559b835358a863eeb/68747470733a2f2f6769746875622d696d616765732e73332e616d617a6f6e6177732e636f6d2f626c6f672f323031312f736563726574732f776869746573706163652e706e67) + +[*Read more about GitHub secrets.*](https://github.com/blog/967-github-secrets) + +### Adjust Tab Space +Adding `?ts=4` to a diff or file URL will display tab characters as 4 spaces wide instead of the default 8. The number after `ts` can be adjusted to suit your preference. This does not work on Gists, or raw file views. + +Here is a Go source file [before](https://github.com/pengwynn/flint/blob/master/flint/flint.go) adding `?ts=4`: + +![Before, tab space example](http://i.imgur.com/GIT1Fr0.png) + +...and this is [after](https://github.com/pengwynn/flint/blob/master/flint/flint.go?ts=4) adding `?ts=4`: + +![After, tab space example](http://i.imgur.com/70FL4H9.png) + +### Commit History by Author +To view all commits on a repo by author add `?author=username` to the URL. + +``` +https://github.com/rails/rails/commits/master?author=dhh +``` + +![DHH commit history](http://i.imgur.com/mDWwuaY.png) + +[*Read more about the differences between commits views.*](https://help.github.com/articles/differences-between-commit-views) + +### Cloning a Repository +When cloning a repository the `.git` can be left off the end. + +```bash +$ git clone https://github.com/tiimgreen/github-cheat-sheet +``` + +[*Read more about the Git `clone` command.*](http://git-scm.com/docs/git-clone) + +### Comparing Branches +To use GitHub to compare branches, change the URL to look like this: + +``` +https://github.com/user/repo/compare/{range} +``` + +Where `{range} = master...4-1-stable` + +For example: + +``` +https://github.com/rails/rails/compare/master...4-1-stable +``` + +![Rails branch compare example](http://i.imgur.com/0Z52X5Y.png) + +`{range}` can be changed to things like: + +``` +https://github.com/rails/rails/compare/master@{1.day.ago}...master +https://github.com/rails/rails/compare/master@{2014-10-04}...master +``` + +*Dates are in the format `YYYY-DD-MM`* + +![Another compare example](http://i.imgur.com/5dtzESz.png) + +...which allows you to see the difference on the master branch up a set time ago or a specified date. + +[*Read more about comparing commits across time.*](https://help.github.com/articles/comparing-commits-across-time) + +### Compare Branches across Forked Repositories +To use GitHub to compare branches across forked repositories, change the URL to look like this: + +``` +https://github.com/user/repo/compare/{foreign-user}:{branch}...{own-branch} +``` + +For example: + +``` +https://github.com/rails/rails/compare/byroot:master...master +``` + +![Forked branch compare](http://i.imgur.com/Q1W6qcB.png) + +### Gists +[Gists](https://gist.github.com/) are an easy way to work with small bits of code without creating a fully fledged repository. + +![Gist](http://i.imgur.com/VkKI1LC.png?1) + +Add `.pibb` to the end of any Gist URL ([like this](https://gist.github.com/tiimgreen/10545817.pibb)) in order to get the *HTML only* version suitable for embedding in any other site. + +Gists can be treated as a full repository so they can be cloned like any other: + +```bash +$ git clone https://gist.github.com/tiimgreen/10545817 +``` + +![Gists](http://i.imgur.com/dULZXXo.png) + +[*Read more about creating gists.*](https://help.github.com/articles/creating-gists) + +### Git.io +[Git.io](http://git.io) is a simple URL shortener for GitHub. + +![Git.io](http://i.imgur.com/6JUfbcG.png?1) + +You can also use it via pure HTTP using Curl: + +```bash +$ curl -i http://git.io -F "url=https://github.com/..." +HTTP/1.1 201 Created +Location: http://git.io/abc123 + +$ curl -i http://git.io/abc123 +HTTP/1.1 302 Found +Location: https://github.com/... +``` + +[*Read more about Git.io.*](https://github.com/blog/985-git-io-github-url-shortener) + +### Keyboard Shortcuts +When on a repository page, keyboard shortcuts allow you to navigate easily. + + - Pressing `t` will bring up a file explorer. + - Pressing `w` will bring up the branch selector. + - Pressing `s` will select the Command Bar. + - Pressing `l` will edit labels on existing Issues. + - Pressing `y` **when looking at a file** (e.g. `https://github.com/tiimgreen/github-cheat-sheet/blob/master/README.md`) will change your URL to one which, in effect, freezes the page you are looking at. If this code changes, you will still be able to see what you saw at that current time. + +To see all of the shortcuts for the current page press `?`: + +![Keyboard shortcuts](http://i.imgur.com/y5ZfNEm.png) + +[*Read more about using the Command Bar.*](https://help.github.com/articles/using-the-command-bar) + +### Line Highlighting in Repositories +Either adding `#L52` to the end of a code file URL or simply clicking the line number will highlight that line number. + +It also works with ranges, e.g. `#L53-L60`, to select ranges, hold `shift` and click two lines: + +``` +https://github.com/rails/rails/blob/master/activemodel/lib/active_model.rb#L53-L60 +``` + +![Line Highlighting](http://i.imgur.com/8AhjrCz.png) + +### Closing Issues via Commit Messages +If a particular commit fixes an issue, any of the keywords `fix/fixes/fixed`, `close/closes/closed` or `resolve/resolves/resolved`, followed by the issue number, will close the issue once it is committed to the master branch. + +```bash +$ git commit -m "Fix screwup, fixes #12" +``` + +This closes the issue and references the closing commit. + +![Closing Repo](http://i.imgur.com/Uh1gZdx.png) + +[*Read more about closing Issues via commit messages.*](https://help.github.com/articles/closing-issues-via-commit-messages) + +### Cross-Link Issues +If you want to link to another issue in the same repository, simple type hash `#` then the issue number, it will be auto-linked. + +To link to an issue in another repository, `user_name/repo_name#ISSUE_NUMBER` e.g. `tiimgreen/toc#12`. + +![Cross-Link Issues](https://camo.githubusercontent.com/447e39ab8d96b553cadc8d31799100190df230a8/68747470733a2f2f6769746875622d696d616765732e73332e616d617a6f6e6177732e636f6d2f626c6f672f323031312f736563726574732f7265666572656e6365732e706e67) + +### CI Status on Pull Requests +If set up correctly, every time you receive a Pull Request, [Travis CI](https://travis-ci.org/) will build that Pull Request just like it would every time you make a new commit. Read more about how to [get started with Travis CI](http://docs.travis-ci.com/user/getting-started/). + +[![Travic CI status](https://cloud.githubusercontent.com/assets/1687642/2700187/3a88838c-c410-11e3-9a46-e65e2a0458cd.png)](https://github.com/octokit/octokit.rb/pull/452) + +[*Read more about the commit status API.*](https://github.com/blog/1227-commit-status-api) + +### Syntax Highlighting in Markdown Files +For example, to syntax highlight Ruby code in your Markdown files write: + + ```ruby + require 'tabbit' + table = Tabbit.new('Name', 'Email') + table.add_row('Tim Green', 'tiimgreen@gmail.com') + puts table.to_s + ``` + +This will produce: + +```ruby +require 'tabbit' +table = Tabbit.new('Name', 'Email') +table.add_row('Tim Green', 'tiimgreen@gmail.com') +puts table.to_s +``` + +GitHub uses [Linguist](https://github.com/github/linguist) to perform language detection and syntax highlighting. You can find out which keywords are valid by perusing the [languages YAML file](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml). + +[*Read more about GitHub Flavored Markdown.*](https://help.github.com/articles/github-flavored-markdown) + +### Emojis +Emojis can added to on Pull Requests, Issues, commit messages, Markdown files, etc. using `:name_of_emoji:`: + +``` +:smile: +``` + +Would produce: + +:smile: + +The full list of supported Emojis on GitHub can be found at [emoji-cheat-sheet.com](http://www.emoji-cheat-sheet.com/) or [scotch-io/All-Github-Emoji-Icons](https://github.com/scotch-io/All-Github-Emoji-Icons). + +The top 5 used Ejmojis on GitHub are: + +1. :shipit: - `:shipit:` +2. :sparkles: - `:sparkles:` +3. :-1: - `:-1:` +4. :+1: - `:+1:` +5. :clap: - `:clap:` + +### Images/GIFs +Images and GIFs can be added to comments, READMEs etc.: + +``` +![Alt Text](http://www.sheawong.com/wp-content/uploads/2013/08/keephatin.gif) +``` + +![Peter don't care](http://www.sheawong.com/wp-content/uploads/2013/08/keephatin.gif) + +All images are cached on GitHub, so if your host goes down, the image will remain available. + +#### Embedding Images in GitHub Wiki +There are multiple ways of embedding images in Wiki pages. There's the standard Markdown syntax (shown above). But there's also a syntax that allows things like specifying the height or width of the image: + +```markdown +[[ http://www.sheawong.com/wp-content/uploads/2013/08/keephatin.gif | height = 100px ]] +``` + +Which produces: + +![Just a screenshot](http://i.imgur.com/J5bMf7S.png) + +### Quick Quoting +When on a comment thread and you want to quote something someone previously said, highlight the text and press `r`, this will copy it into your text box in the block-quote format. + +![Quick Quote](https://f.cloud.github.com/assets/296432/124483/b0fa6204-6ef0-11e2-83c3-256c37fa7abc.gif) + +[*Read more about quick quoting.*](https://github.com/blog/1399-quick-quotes) + +### Quick Licensing +When creating a repository GitHub gives you the options of adding in a pre-made license: + +![License](http://i.imgur.com/Chqj4Fg.png) + +You can also add them to existing repositories by creating a new file through the web interface. When the name `LICENSE` is typed in you will get an option to use a template: + +![License](http://i.imgur.com/fTjQict.png) + +Also works for `.gitignore`. + +[*Read more about open source licensing.*](https://help.github.com/articles/open-source-licensing) + +### Task Lists +In Issues and Pull requests check boxes can be added with the following syntax (notice the space): + +``` +- [ ] Be awesome +- [ ] Do stuff +- [ ] Sleep +``` + +![Task List](http://i.imgur.com/k2qZi56.png) + +When they are clicked, they will be updated in the pure Markdown: + +``` +- [x] Be awesome +- [x] Do stuff +- [ ] Sleep +``` + +[*Read more about task lists.*](https://github.com/blog/1375%0A-task-lists-in-gfm-issues-pulls-comments) + +### Relative Links +Relative links are recommended in your Markdown files when linking to internal content. + +```markdown +[Link to a header](#awesome-section) +[Link to a file](docs/readme) +``` + +Absolute links have to be updated whenever the URL changes (e.g. repository renamed, username changed, project forked). Using relative links makes your documentation easily stand on its own. + +[*Read more about relative links.*](https://help.github.com/articles/relative-links-in-readmes) + +### Metadata and Plugin Support for GitHub Pages +Within Jekyll pages and posts, repository information is available within the `site.github` namespace, and can be displayed, for example, using `{{ site.github.project_title }}`. + +The Jemoji and jekyll-mentions plugins enable [emoji](#emojis) and [@mentions](https://github.com/blog/821) in your Jekyll posts and pages to work just like you'd expect when interacting with a repository on GitHub.com. + +[*Read more about repository metadata and plugin support for GitHub Pages.*](https://github.com/blog/1797-repository-metadata-and-plugin-support-for-github-pages) + +### Viewing YAML Metadata in your Documents +Many blogging websites, like [Jekyll](http://jekyllrb.com/) with [GitHub Pages](http://pages.github.com/), depend on some YAML-formatted metadata at the beginning of your post. GitHub will render this metadata as a horizontal table, for easier reading + +![YAML metadata](https://camo.githubusercontent.com/47245aa16728e242f74a9a324ce0d24c0b916075/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f36343035302f313232383236372f65303439643063362d323761302d313165332d396464382d6131636432323539393334342e706e67) + +[*Read more about viewing YAML metadata in your documents.*](https://github.com/blog/1647-viewing-yaml-metadata-in-your-documents) + +### Rendering Tabular Data +GitHub supports rendering tabular data in the form of `.csv` (comma-separated) and `.tsv` (tab-separated) files. + +![Tabular data](https://camo.githubusercontent.com/1b6dd0157ffb45d9939abf14233a0cb13b3b4dfe/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f3238323735392f3937363436322f33323038336463652d303638642d313165332d393262322d3566323863313061353035392e706e67) + +[*Read more about rendering tabular data.*](https://github.com/blog/1601-see-your-csvs) + +### Diffs +#### Rendered Prose Diffs +Commits and pull requests including rendered documents supported by GitHub (e.g. Markdown) feature *source* and *rendered* views. + +![Source / Rendered view](https://github-images.s3.amazonaws.com/help/repository/rendered_prose_diff.png) + +Click the "rendered" button to see the changes as they'll appear in the rendered document. Rendered prose view is handy when you're adding, removing, and editing text: + +![Rendered Prose Diffs](https://f.cloud.github.com/assets/17715/2003056/3997edb4-862b-11e3-90be-5e9586edecd7.png) + +[*Read more about rendered prose diffs.*](https://github.com/blog/1784-rendered-prose-diffs) + +#### Diffable Maps +Any time you view a commit or pull request on GitHub that includes geodata, GitHub will render a visual representation of what was changed. + +[![Diffable Maps](https://f.cloud.github.com/assets/282759/2090660/63f2e45a-8e97-11e3-9d8b-d4c8078b004e.gif)](https://github.com/benbalter/congressional-districts/commit/2233c76ca5bb059582d796f053775d8859198ec5) + +[*Read more about diffable maps.*](https://github.com/blog/1772-diffable-more-customizable-maps) + +#### Expanding Context in Diffs +Using the *unfold* button in the gutter of a diff, you can reveal additional lines of context with a click. You can keep clicking *unfold* until you've revealed the whole file, and the feature is available anywhere GitHub renders diffs. + +![Expanding Context in Diffs](https://f.cloud.github.com/assets/22635/1610539/863c1f64-5584-11e3-82bf-151b406a272f.gif) + +[*Read more about expanding context in diffs.*](https://github.com/blog/1705-expanding-context-in-diffs) + +#### Diff or Patch of Pull Request +You can get the diff of a Pull Request by adding a `.diff` or `.patch` +extension to the end of the URL. For example: + +``` +https://github.com/tiimgreen/github-cheat-sheet/pull/15 +https://github.com/tiimgreen/github-cheat-sheet/pull/15.diff +https://github.com/tiimgreen/github-cheat-sheet/pull/15.patch +``` + +The `.diff` extension would give you this in plain text: + +``` +diff --git a/README.md b/README.md +index 88fcf69..8614873 100644 +--- a/README.md ++++ b/README.md +@@ -28,6 +28,7 @@ All the hidden and not hidden features of Git and GitHub. This cheat sheet was i + - [Merged Branches](#merged-branches) + - [Quick Licensing](#quick-licensing) + - [TODO Lists](#todo-lists) ++- [Relative Links](#relative-links) + - [.gitconfig Recommendations](#gitconfig-recommendations) + - [Aliases](#aliases) + - [Auto-correct](#auto-correct) +@@ -381,6 +382,19 @@ When they are clicked, they will be updated in the pure Markdown: + - [ ] Sleep + +(...) +``` + +### Hub +[Hub](https://github.com/github/hub) is a command line Git wrapper that gives you extra features and commands that make working with GitHub easier. + +This allows you to do things like: + +```bash +$ hub clone tiimgreen/toc +``` + +[*Check out some more cool commands Hub has to offer.*](https://github.com/github/hub#commands) + +### Decreasing Contributor Friction +If you want people to use and contribute to your project, you need to start by answering their most basic questions. What does the project do? How do I use it? How am I allowed to use it? How do I contribute? How do I get up and running in development? How do I make sure my new features didn't break old functionality? + +[Friction](https://github.com/rafalchmiel/friction) is a command line script that will check your project for common [answers to these questions](https://github.com/rafalchmiel/friction/wiki). This is some example output: + +[![Friction output](http://i.imgur.com/4EgpWo4.png)](https://github.com/rafalchmiel/friction) + +*Friction supports MRI 2.1.0, MRI 2.0.0, and MRI 1.9.3.* + +### Contributing Guidelines +Adding a `CONTRIBUTING` file to the root of your repository will add a link to your file when a contributor creates an Issue or opens a Pull Request. + +![Contributing Guidelines](https://camo.githubusercontent.com/71995d6b0e620a9ef1ded00a04498241c69dd1bf/68747470733a2f2f6769746875622d696d616765732e73332e616d617a6f6e6177732e636f6d2f736b697463682f6973737565732d32303132303931332d3136323533392e6a7067) + +[*Read more about contributing guidelines.*](https://github.com/blog/1184-contributing-guidelines) + +### GitHub Resources +| Title | Link | +| ----- | ---- | +| GitHub Explore | https://github.com/explore | +| GitHub Blog | https://github.com/blog | +| GitHub Help | https://help.github.com/ | +| GitHub Training | http://training.github.com/ | +| GitHub Developer | https://developer.github.com/ | + +#### GitHub Talks +| Title | Link | +| ----- | ---- | +| How GitHub Uses GitHub to Build GitHub | https://www.youtube.com/watch?v=qyz3jkOBbQY | +| Introduction to Git with Scott Chacon of GitHub | https://www.youtube.com/watch?v=ZDR433b0HJY | +| How GitHub No Longer Works | https://www.youtube.com/watch?v=gXD1ITW7iZI | +| Git and GitHub Secrets | https://www.youtube.com/watch?v=Foz9yvMkvlA | +| More Git and GitHub Secrets | https://www.youtube.com/watch?v=p50xsL-iVgU | + +## Git +### Previous Branch +To move to the previous branch in Git: + +```bash +$ git checkout - +# Switched to branch 'master' + +$ git checkout - +# Switched to branch 'next' + +$ git checkout - +# Switched to branch 'master' +``` + +[*Read more about Git branching.*](http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging) + +### Stripspace + +Git Stripspace: + +- Strips trailing whitespace +- Collapses newlines +- Adds newline to end of file + +A file must be passed when calling the command, e.g.: +```bash +$ git stripspace < README.md +``` + +[*Read more about the Git `stripspace` command.*](http://git-scm.com/docs/git-stripspace) + +### Checking out Pull Requests +If you want to check out pull request locally, you can fetch it using that command: + +```bash +$ git fetch origin '+refs/pull/*/head:refs/pull/*' +``` + +then, checkout Pull Request (i.e. 42) using + +```bash +$ git checkout refs/pull/42 +``` + +Alternatively, you can fetch them as remote branches: + +```bash +$ git fetch origin '+refs/pull/*/head:refs/remotes/origin/pr/*' +``` + +and checkout as: + +```bash +$ git checkout origin/pr/42 +``` + +and even fetch them automatically, if you add corresponding lines in your .git/config: + + +``` +[remote "origin"] + fetch = +refs/heads/*:refs/remotes/origin/* + url = git@github.com:tiimgreen/github-cheat-sheet.git +``` + +``` +[remote "origin"] + fetch = +refs/heads/*:refs/remotes/origin/* + url = git@github.com:tiimgreen/github-cheat-sheet.git + fetch = +refs/pull/*/head:refs/remotes/origin/pr/* +``` + +[*Read more about checking out pull requests locally.*](https://help.github.com/articles/checking-out-pull-requests-locally) + +### Empty Commits :trollface: +Commits can be pushed with no code changes by adding `--allow-empty`: + +```bash +$ git commit -m "Big-ass commit" --allow-empty +``` + +Some use-cases for this (that make sense), include: + + - Annotating the start of a new bulk of work or a new feature. + - Documenting when you make changes to the project that aren't code related. + - Communicating with people using your repository. + - The first commit of a repo, as the first commit cannot be rebased later: `git commit -m "init repo" --allow-empty`. + +### Styled Git Status +Running: + +```bash +$ git status +``` + +Produces: + +![git status](http://i.imgur.com/o3PEHAA.png) + +By adding `-sb`: + +```bash +$ git status -sb +``` + +This is produced: + +![git status -sb](http://i.imgur.com/xNI1bT0.png) + +[*Read more about the Git `status` command.*](http://git-scm.com/docs/git-status) + +### Styled Git Log +Running: + +```bash +$ git log --all --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative +``` + +Produces: + +![git log --all --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative](http://i.imgur.com/R2z8l7c.png) + +Credit to [Palesz](http://stackoverflow.com/users/88355/palesz) + +*This can be aliased using the instructions found [here](https://github.com/tiimgreen/github-cheat-sheet#aliases).* + +[*Read more about the Git `log` command.*](http://git-scm.com/docs/git-log) + +### Git Query +A Git query allows you to search all your previous commit messages and find the most recent one matching the query. + +```bash +$ git show :/query +``` + +Where `query` (case-sensitive) is the term you want to search, this then finds the last one and gives details on the lines that were changed. + +```bash +$ git show :/typo +``` +![git show :/query](http://i.imgur.com/icaGiNt.png) + +*Press `q` to quit.* + +### Merged Branches +Running: + +```bash +$ git branch --merged +``` + +Will give you a list of all branches that have been merged into your current branch. + +Conversely: + +```bash +$ git branch --no-merged +``` + +Will give you a list of branches that have not been merged into your current branch. + +[*Read more about the Git `branch` command.*](http://git-scm.com/docs/git-branch) + +### Web Server for Browsing Local Repositories +Use the Git `instaweb` command to instantly browse your working repository in `gitweb`. This command is a simple script to set up `gitweb` and a web server for browsing the local repository. + +```bash +$ git instaweb +``` + +Opens: + +![Git instaweb](http://i.imgur.com/Dxekmqc.png) + +[*Read more about the Git `instaweb` command.*](http://git-scm.com/docs/git-instaweb) + +### Git Configurations +Your `.gitconfig` file contains all your Git configurations. + +#### Aliases +Aliases are helpers that let you define your own git calls. For example you could set `git a` to run `git add --all`. + +To add an alias, either navigate to `~/.gitconfig` and fill it out in the following format: + +``` +[alias] + co = checkout + cm = commit + p = push + # Show verbose output about tags, branches or remotes + tags = tag -l + branches = branch -a + remotes = remote -v +``` + +...or type in the command-line: + +```bash +$ git config --global alias.new_alias git_function +``` + +For example: + +```bash +$ git config --global alias.cm commit +``` + +For an alias with multiple functions use quotes: + +```bash +$ git config --global alias.ac 'add -A . && commit' +``` + +Some useful aliases include: + +| Alias | Command | What to Type | +| --- | --- | --- | +| `git cm` | `git commit` | `git config --global alias.cm commit` | +| `git co` | `git checkout` | `git config --global alias.co checkout` | +| `git ac` | `git add . -A` `git commit` | `git config --global alias.ac '!git add -A && git commit'` | +| `git st` | `git status -sb` | `git config --global alias.st 'status -sb'` | +| `git tags` | `git tag -l` | `git config --global alias.tags 'tag -l'` | +| `git branches` | `git branch -a` | `git config --global alias.branches 'branch -a'` | +| `git remotes` | `git remote -v` | `git config --global alias.remotes 'remote -v'` | + +#### Auto-Correct +If you type `git comit` you will get this: + +```bash +$ git comit -m "Message" +# git: 'comit' is not a git command. See 'git --help'. + +# Did you mean this? +# commit +``` + +To call `commit` when `comit` is typed, just enable auto-correct: + +```bash +$ git config --global help.autocorrect 1 +``` + +So now you will get this: + +```bash +$ git comit -m "Message" +# WARNING: You called a Git command named 'comit', which does not exist. +# Continuing under the assumption that you meant 'commit' +# in 0.1 seconds automatically... +``` + +#### Color +To add more color to your Git output: + +```bash +$ git config --global color.ui 1 +``` + +[*Read more about the Git `config` command.*](http://git-scm.com/docs/git-config) + +### Git Resources +| Title | Link | +| ----- | ---- | +| Official Git Site | http://git-scm.com/ | +| Official Git Video Tutorials | http://git-scm.com/videos | +| Code School Try Git | http://try.github.com/ | +| Introductory Reference & Tutorial for Git | http://gitref.org/ | +| Official Git Tutorial | http://git-scm.com/docs/gittutorial | +| Everyday Git | http://git-scm.com/docs/everyday | +| Git Immersion | http://gitimmersion.com/ | +| Ry's Git Tutorial | http://rypress.com/tutorials/git/index.html | +| Git for Designer | http://hoth.entp.com/output/git_for_designers.html | +| Git for Computer Scientists | http://eagain.net/articles/git-for-computer-scientists/ | +| Git Magic | http://www-cs-students.stanford.edu/~blynn/gitmagic/ | + +#### Git Books +| Title | Link | +| ----- | ---- | +| Pragmatic Version Control Using Git | http://www.pragprog.com/titles/tsgit/pragmatic-version-control-using-git | +| Pro Git | http://git-scm.com/book | +| Git Internals Peepcode | http://peepcode.com/products/git-internals-pdf | +| Git in the Trenches | http://cbx33.github.com/gitt/ | +| Version Control with Git | http://www.amazon.com/Version-Control-Git-collaborative-development/dp/1449316387 | +| Pragmatic Guide to Git | http://www.pragprog.com/titles/pg_git/pragmatic-guide-to-git | +| Git: Version Control for Everyone | http://www.packtpub.com/git-version-control-for-everyone/book | From 628f269d5072960ce843bcaec82fc6614032be30 Mon Sep 17 00:00:00 2001 From: wolfg1969 Date: Mon, 28 Apr 2014 21:12:10 +0800 Subject: [PATCH 2/4] add zh-cn translation --- README.ja.md | 2 +- README.ko.md | 2 +- README.md | 2 +- README.zh-cn.md | 498 ++++++++++++++++++++++++------------------------ 4 files changed, 255 insertions(+), 249 deletions(-) diff --git a/README.ja.md b/README.ja.md index 735f2d9..2646143 100644 --- a/README.ja.md +++ b/README.ja.md @@ -1,7 +1,7 @@ # GitHubカンニング・ペーパー これはGitやGitHubの隠された機能やよく知られていない機能の一覧だ。[Zach Holman](https://github.com/holman)によるAloha Ruby Conference 2012での[Git and GitHub Secrets](https://github.com/tiimgreen/github-cheat-sheet)([スライド](https://github.com/tiimgreen/github-cheat-sheet))とWDCNZ 2013での[More Git and GitHub Secrets](https://vimeo.com/72955426)([スライド](https://speakerdeck.com/holman/more-git-and-github-secrets))の二つのトークを元にしている。 -*Read this in other languages: [English](README.md), [한국어](README.ko.md), [日本語](README.ja.md).* +*Read this in other languages: [English](README.md), [한국어](README.ko.md), [日本語](README.ja.md), [简体中文](README.zh-cn.md).* # 目次 - [GitHub](#github) diff --git a/README.ko.md b/README.ko.md index 3ddc32d..f6549ce 100644 --- a/README.ko.md +++ b/README.ko.md @@ -2,7 +2,7 @@ A collection of cool hidden and not so hidden features of Git and GitHub. This cheat sheet was inspired by [Zach Holman](https://github.com/holman)'s [Git and GitHub Secrets](http://www.confreaks.com/videos/1229-aloharuby2012-git-and-github-secrets) talk at Aloha Ruby Conference 2012 ([slides](https://speakerdeck.com/holman/git-and-github-secrets)) and his [More Git and GitHub Secrets](https://vimeo.com/72955426) talk at WDCNZ 2013 ([slides](https://speakerdeck.com/holman/more-git-and-github-secrets)). -*Read this in other languages: [English](README.md), [한국어](README.ko.md), [日本語](README.ja.md).* +*Read this in other languages: [English](README.md), [한국어](README.ko.md), [日本語](README.ja.md), [简体中文](README.zh-cn.md).* # 목록 diff --git a/README.md b/README.md index 89a47e8..f0b9a92 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # GitHub Cheat Sheet A collection of cool hidden and not so hidden features of Git and GitHub. This cheat sheet was inspired by [Zach Holman](https://github.com/holman)'s [Git and GitHub Secrets](http://www.confreaks.com/videos/1229-aloharuby2012-git-and-github-secrets) talk at Aloha Ruby Conference 2012 ([slides](https://speakerdeck.com/holman/git-and-github-secrets)) and his [More Git and GitHub Secrets](https://vimeo.com/72955426) talk at WDCNZ 2013 ([slides](https://speakerdeck.com/holman/more-git-and-github-secrets)). -*Read this in other languages: [English](README.md), [한국어](README.ko.md), [日本語](README.ja.md).* +*Read this in other languages: [English](README.md), [한국어](README.ko.md), [日本語](README.ja.md), [简体中文](README.zh-cn.md).* ## Table of Contents - [GitHub](#github) diff --git a/README.zh-cn.md b/README.zh-cn.md index 89a47e8..dad5fdd 100644 --- a/README.zh-cn.md +++ b/README.zh-cn.md @@ -1,82 +1,83 @@ -# GitHub Cheat Sheet -A collection of cool hidden and not so hidden features of Git and GitHub. This cheat sheet was inspired by [Zach Holman](https://github.com/holman)'s [Git and GitHub Secrets](http://www.confreaks.com/videos/1229-aloharuby2012-git-and-github-secrets) talk at Aloha Ruby Conference 2012 ([slides](https://speakerdeck.com/holman/git-and-github-secrets)) and his [More Git and GitHub Secrets](https://vimeo.com/72955426) talk at WDCNZ 2013 ([slides](https://speakerdeck.com/holman/more-git-and-github-secrets)). +# GitHub秘籍 +本秘籍收录了一些Git和Github非常酷同时又少有人知的功能。灵感来自于[Zach Holman](https://github.com/holman)在2012年Aloha Ruby Conference和2013年WDCNZ上所做的演讲:[Git and GitHub Secrets](http://www.confreaks.com/videos/1229-aloharuby2012-git-and-github-secrets)([slides](https://speakerdeck.com/holman/git-and-github-secrets))和[More Git and GitHub Secrets](https://vimeo.com/72955426)([slides](https://speakerdeck.com/holman/more-git-and-github-secrets))。 -*Read this in other languages: [English](README.md), [한국어](README.ko.md), [日本語](README.ja.md).* +*Read this in other languages: [English](README.md), [한국어](README.ko.md), [日本語](README.ja.md), [简体中文](README.zh-cn.md).* ## Table of Contents - - [GitHub](#github) - - [Ignore Whitespace](#ignore-whitespace) - - [Adjust Tab Space](#adjust-tab-space) - - [Commit History by Author](#commit-history-by-author) - - [Cloning a Repository](#cloning-a-repository) - - [Comparing Branches](#comparing-branches) - - [Compare Branches across Forked Repositories](#compare-branches-across-forked-repositories) + - [GitHub篇](#github) + - [忽略空白字符](#ignore-whitespace) + - [调整缩进宽度](#adjust-tab-space) + - [查看某个用户的提交历史](#commit-history-by-author) + - [克隆仓库](#cloning-a-repository) + - [比较分支](#comparing-branches) + - [派生仓库之间比较分支](#compare-branches-across-forked-repositories) - [Gists](#gists) - [Git.io](#gitio) - - [Keyboard Shortcuts](#keyboard-shortcuts) - - [Line Highlighting in Repositories](#line-highlighting-in-repositories) - - [Closing Issues via Commit Messages](#closing-issues-via-commit-messages) - - [Cross-Link Issues](#cross-link-issues) - - [CI Status on Pull Requests](#ci-status-on-pull-requests) - - [Syntax Highlighting in Markdown Files](#syntax-highlighting-in-markdown-files) - - [Emojis](#emojis) - - [Images/GIFs](#imagesgifs) - - [Embedding Images in GitHub Wiki](#embedding-images-in-github-wiki) - - [Quick Quoting](#quick-quoting) - - [Quick Licensing](#quick-licensing) - - [Task Lists](#task-lists) - - [Relative Links](#relative-links) - - [Metadata and Plugin Support for GitHub Pages](#metadata-and-plugin-support-for-github-pages) - - [Viewing YAML Metadata in your Documents](#viewing-yaml-metadata-in-your-documents) - - [Rendering Tabular Data](#rendering-tabular-data) + - [快捷键](#keyboard-shortcuts) + - [高亮显示一行或多行代码](#line-highlighting-in-repositories) + - [通过提交信息关闭Issue](#closing-issues-via-commit-messages) + - [链接Issue](#cross-link-issues) + - [Pull Requests的CI结果](#ci-status-on-pull-requests) + - [在Markdown文件中使用语法高亮](#syntax-highlighting-in-markdown-files) + - [表情符号](#emojis) + - [图片/GIF动画](#imagesgifs) + - [在Github Wiki里嵌入图片](#embedding-images-in-github-wiki) + - [快速引用文本](#quick-quoting) + - [快速选择软件许可](#quick-licensing) + - [任务列表](#task-lists) + - [相对链接](#relative-links) + - [GitHub Pages的元数据和插件支持](#metadata-and-plugin-support-for-github-pages) + - [在文档里查看YAML元数据](#viewing-yaml-metadata-in-your-documents) + - [渲染表格数据](#rendering-tabular-data) - [Diffs](#diffs) - - [Rendered prose Diffs](#rendered-prose-diffs) - - [Diffable Maps](#diffable-maps) - - [Expanding Context in Diffs](#expanding-context-in-diffs) - - [Diff or Patch of Pull Request](#diff-or-patch-of-pull-request) + - [渲染单调的Diff](#rendered-prose-diffs) + - [可比较地图](#diffable-maps) + - [扩展Diff上下文](#expanding-context-in-diffs) + - [Pull Request的Diff或Patch](#diff-or-patch-of-pull-request) - [Hub](#hub) - - [Decreasing Contributor Friction](#decreasing-contributor-friction) - - [Contributing Guidelines](#contributing-guidelines) - - [GitHub Resources](#github-resources) + - [减少贡献者冲突](#decreasing-contributor-friction) + - [贡献者指南](#contributing-guidelines) + - [GitHub 参考资源](#github-resources) - [GitHub Talks](#github-talks) - - [Git](#git) - - [Previous Branch](#previous-branch) - - [Stripspace](#stripspace) - - [Checking out Pull Requests](#checking-out-pull-requests) - - [Empty Commits :trollface:](#empty-commits-trollface) - - [Styled Git Status](#styled-git-status) - - [Styled Git Log](#styled-git-log) - - [Git Query](#git-query) - - [Merged Branches](#merged-branches) - - [Web Server for Browsing Local Repositories](#web-server-for-browsing-local-repositories) - - [Git Configurations](#git-configurations) - - [Aliases](#aliases) - - [Auto-Correct](#auto-correct) - - [Color](#color) - - [Git Resources](#git-resources) - - [Git Books](#git-books) + - [Git篇](#git) + - [上个分支](#previous-branch) + - [去除空白](#stripspace) + - [检出 Pull Requests](#checking-out-pull-requests) + - [空提交 :trollface:](#empty-commits-trollface) + - [给 Git Status 命令加样式](#styled-git-status) + - [给 Git Log 命令加样式](#styled-git-log) + - [Git 查询](#git-query) + - [已合并的分支](#merged-branches) + - [用于浏览本地参考的Web服务器](#web-server-for-browsing-local-repositories) + - [Git 配置](#git-configurations) + - [别名](#aliases) + - [自动纠错](#auto-correct) + - [颜色](#color) + - [Git 参考资源](#git-resources) + - [Git 书籍](#git-books) -## GitHub -### Ignore Whitespace -Adding `?w=1` to any diff URL will remove any changes only in whitespace, enabling you to see only that code that has changed. +## GitHub篇 +### 忽略空白字符 + +在任意diff页面的URL后加上`?w=1`,可以去掉那些只是空白字符的变化,使你能更专注于代码的变化。 ![Diff without whitespace](https://camo.githubusercontent.com/797184940defadec00393e6559b835358a863eeb/68747470733a2f2f6769746875622d696d616765732e73332e616d617a6f6e6177732e636f6d2f626c6f672f323031312f736563726574732f776869746573706163652e706e67) -[*Read more about GitHub secrets.*](https://github.com/blog/967-github-secrets) +[*详见 GitHub secrets.*](https://github.com/blog/967-github-secrets) -### Adjust Tab Space -Adding `?ts=4` to a diff or file URL will display tab characters as 4 spaces wide instead of the default 8. The number after `ts` can be adjusted to suit your preference. This does not work on Gists, or raw file views. +### 调整缩进宽度 +在diff或者file页面的URL后面加上`?ts=4`,这样当显示tab字符的长度时就会是4个空格的长度,不再是默认的8个空格。`ts`后面的数字还可以根据你个人的偏好进行修改。不过,这个小诀窍在Gists页面和raw file页面不起作用。 -Here is a Go source file [before](https://github.com/pengwynn/flint/blob/master/flint/flint.go) adding `?ts=4`: +下面是我们在Go语言的source file页面URL后加`?ts=4`[前](https://github.com/pengwynn/flint/blob/master/flint/flint.go)的例子: ![Before, tab space example](http://i.imgur.com/GIT1Fr0.png) -...and this is [after](https://github.com/pengwynn/flint/blob/master/flint/flint.go?ts=4) adding `?ts=4`: +然后是我们添加`?ts=4`[后](https://github.com/pengwynn/flint/blob/master/flint/flint.go?ts=4)的例子: ![After, tab space example](http://i.imgur.com/70FL4H9.png) -### Commit History by Author -To view all commits on a repo by author add `?author=username` to the URL. +### 查看某个用户的提交历史 +查看某个用户的所有提交历史,只需在commits页面URL后加上`?author=username`。 ``` https://github.com/rails/rails/commits/master?author=dhh @@ -84,27 +85,28 @@ https://github.com/rails/rails/commits/master?author=dhh ![DHH commit history](http://i.imgur.com/mDWwuaY.png) -[*Read more about the differences between commits views.*](https://help.github.com/articles/differences-between-commit-views) +[*深入了解提交视图之间的区别*](https://help.github.com/articles/differences-between-commit-views) -### Cloning a Repository -When cloning a repository the `.git` can be left off the end. +### 克隆仓库 +当我们克隆某一资源时,可以不要那个`.git`后缀。 ```bash $ git clone https://github.com/tiimgreen/github-cheat-sheet ``` -[*Read more about the Git `clone` command.*](http://git-scm.com/docs/git-clone) +[*更多对 Git `clone` 命令的介绍.*](http://git-scm.com/docs/git-clone) -### Comparing Branches -To use GitHub to compare branches, change the URL to look like this: +### 比较分支 + +如果我们想要比较两个分支,可以像下面一样修改URL: ``` https://github.com/user/repo/compare/{range} ``` -Where `{range} = master...4-1-stable` +其中`{range} = master...4-1-stable` -For example: +例如: ``` https://github.com/rails/rails/compare/master...4-1-stable @@ -112,29 +114,30 @@ https://github.com/rails/rails/compare/master...4-1-stable ![Rails branch compare example](http://i.imgur.com/0Z52X5Y.png) -`{range}` can be changed to things like: +`{range}`还可以使用下面的形式: ``` https://github.com/rails/rails/compare/master@{1.day.ago}...master https://github.com/rails/rails/compare/master@{2014-10-04}...master ``` -*Dates are in the format `YYYY-DD-MM`* +*日期格式 `YYYY-DD-MM`* ![Another compare example](http://i.imgur.com/5dtzESz.png) -...which allows you to see the difference on the master branch up a set time ago or a specified date. +...这样你就能查看master分支上一段时间或者指定日期内的改动。 -[*Read more about comparing commits across time.*](https://help.github.com/articles/comparing-commits-across-time) +[*了解更多关于比较跨时间段的提交记录.*](https://help.github.com/articles/comparing-commits-across-time) -### Compare Branches across Forked Repositories -To use GitHub to compare branches across forked repositories, change the URL to look like this: +### 派生仓库之间比较分支 + +想要对派生仓库Forked Repository)之间的分支进行比较,可以像下面这样修改URL实现: ``` https://github.com/user/repo/compare/{foreign-user}:{branch}...{own-branch} ``` -For example: +例如: ``` https://github.com/rails/rails/compare/byroot:master...master @@ -143,13 +146,14 @@ https://github.com/rails/rails/compare/byroot:master...master ![Forked branch compare](http://i.imgur.com/Q1W6qcB.png) ### Gists -[Gists](https://gist.github.com/) are an easy way to work with small bits of code without creating a fully fledged repository. + +[Gists](https://gist.github.com/) 给我们提供了一种不需要创建一个完整的仓库,使小段代码也可以工作的简单方式。 ![Gist](http://i.imgur.com/VkKI1LC.png?1) -Add `.pibb` to the end of any Gist URL ([like this](https://gist.github.com/tiimgreen/10545817.pibb)) in order to get the *HTML only* version suitable for embedding in any other site. +Gist的URL后加上`.pibb`,可以得到更适合嵌入到其他网站的HTML版本。 -Gists can be treated as a full repository so they can be cloned like any other: +Gists还可以像任何标准仓库一样被克隆。 ```bash $ git clone https://gist.github.com/tiimgreen/10545817 @@ -157,14 +161,14 @@ $ git clone https://gist.github.com/tiimgreen/10545817 ![Gists](http://i.imgur.com/dULZXXo.png) -[*Read more about creating gists.*](https://help.github.com/articles/creating-gists) +[*进一步了解如何创建 gists.*](https://help.github.com/articles/creating-gists) ### Git.io -[Git.io](http://git.io) is a simple URL shortener for GitHub. +[Git.io](http://git.io)是Github的短网址服务。 ![Git.io](http://i.imgur.com/6JUfbcG.png?1) -You can also use it via pure HTTP using Curl: +你可以通过Curl命令以普通HTTP协议使用它: ```bash $ curl -i http://git.io -F "url=https://github.com/..." @@ -176,27 +180,29 @@ HTTP/1.1 302 Found Location: https://github.com/... ``` -[*Read more about Git.io.*](https://github.com/blog/985-git-io-github-url-shortener) +[*进一步了解 Git.io.*](https://github.com/blog/985-git-io-github-url-shortener) -### Keyboard Shortcuts -When on a repository page, keyboard shortcuts allow you to navigate easily. +### 快捷键 - - Pressing `t` will bring up a file explorer. - - Pressing `w` will bring up the branch selector. - - Pressing `s` will select the Command Bar. - - Pressing `l` will edit labels on existing Issues. - - Pressing `y` **when looking at a file** (e.g. `https://github.com/tiimgreen/github-cheat-sheet/blob/master/README.md`) will change your URL to one which, in effect, freezes the page you are looking at. If this code changes, you will still be able to see what you saw at that current time. +在仓库主页上提供了快捷键方便快速导航。 -To see all of the shortcuts for the current page press `?`: + - 按 `t` 键会打开一个文件浏览器。 Pressing `t` will bring up a file explorer. + - 按 `w` 键会打开分支选择菜单。 Pressing `w` will bring up the branch selector. + - 按 `s` 键会激活顶端的命令栏 (Command Bar)。Pressing `s` will select the Command Bar. + - 按 `l` 键编辑Issue列表页的标签。 Pressing `l` will edit labels on existing Issues. + - **查看文件内容时**(如:`https://github.com/tiimgreen/github-cheat-sheet/blob/master/README.md`),按 `y` 键将会冻结这个页面,这样就算代码被修改了也不会影响你当前看到的。 + +按`?`查看当前页面支持的快捷键列表: ![Keyboard shortcuts](http://i.imgur.com/y5ZfNEm.png) -[*Read more about using the Command Bar.*](https://help.github.com/articles/using-the-command-bar) +[*进一步了解如何使用 Command Bar.*](https://help.github.com/articles/using-the-command-bar) -### Line Highlighting in Repositories -Either adding `#L52` to the end of a code file URL or simply clicking the line number will highlight that line number. +### 高亮显示一行或多行代码 -It also works with ranges, e.g. `#L53-L60`, to select ranges, hold `shift` and click two lines: +在代码文件地址后加上`#L52`或者单击行号52都会将第52行代码高亮显示。 + +多行高亮也可以,比如用`#L53-L60`选择范围,或者按住 `shift`键,然后再点击选择的两行。 ``` https://github.com/rails/rails/blob/master/activemodel/lib/active_model.rb#L53-L60 @@ -204,35 +210,36 @@ https://github.com/rails/rails/blob/master/activemodel/lib/active_model.rb#L53-L ![Line Highlighting](http://i.imgur.com/8AhjrCz.png) -### Closing Issues via Commit Messages -If a particular commit fixes an issue, any of the keywords `fix/fixes/fixed`, `close/closes/closed` or `resolve/resolves/resolved`, followed by the issue number, will close the issue once it is committed to the master branch. +### 通过提交信息关闭Issue + +如果某个提交修复了一个Issue,当提交到master分支时,提交信息里可以使用`fix/fixes/fixed`, `close/closes/closed` 或者 `resolve/resolves/resolved`等关键词,后面再跟上Issue号,这样就会关闭这个Issue。 ```bash $ git commit -m "Fix screwup, fixes #12" ``` -This closes the issue and references the closing commit. +这将会关闭Issue #12,并且在Issue讨论列表里关联引用这次提交。 ![Closing Repo](http://i.imgur.com/Uh1gZdx.png) -[*Read more about closing Issues via commit messages.*](https://help.github.com/articles/closing-issues-via-commit-messages) +[*进一步了解通过提交信息关闭Issue.*](https://help.github.com/articles/closing-issues-via-commit-messages) -### Cross-Link Issues -If you want to link to another issue in the same repository, simple type hash `#` then the issue number, it will be auto-linked. +### 引用Issue +如果你想引用到同一个仓库中的一个Issue,只需使用井号 `#` 加上Issue号,这样就会自动创建到此Issue的链接。 -To link to an issue in another repository, `user_name/repo_name#ISSUE_NUMBER` e.g. `tiimgreen/toc#12`. +要链接到其他仓库的Issue,就使用`user_name/repo_name#ISSUE_NUMBER`的方式,例如`tiimgreen/toc#12`。 ![Cross-Link Issues](https://camo.githubusercontent.com/447e39ab8d96b553cadc8d31799100190df230a8/68747470733a2f2f6769746875622d696d616765732e73332e616d617a6f6e6177732e636f6d2f626c6f672f323031312f736563726574732f7265666572656e6365732e706e67) -### CI Status on Pull Requests -If set up correctly, every time you receive a Pull Request, [Travis CI](https://travis-ci.org/) will build that Pull Request just like it would every time you make a new commit. Read more about how to [get started with Travis CI](http://docs.travis-ci.com/user/getting-started/). +### Pull Requests的CI结果 +如果配置正确,[Travis CI](https://travis-ci.org/)会为每个你收到的Pull Request执行构建,就像每次提交也会触发构建一样。想了解更多关于Travis CI的信息,请看 [Travis CI入门](http://docs.travis-ci.com/user/getting-started/)。 [![Travic CI status](https://cloud.githubusercontent.com/assets/1687642/2700187/3a88838c-c410-11e3-9a46-e65e2a0458cd.png)](https://github.com/octokit/octokit.rb/pull/452) -[*Read more about the commit status API.*](https://github.com/blog/1227-commit-status-api) +[*进一步了解 Commit status API.*](https://github.com/blog/1227-commit-status-api) -### Syntax Highlighting in Markdown Files -For example, to syntax highlight Ruby code in your Markdown files write: +### 在Markdown文件中使用语法高亮 +例如,可以像下面这样在你的Markdown文件里为Ruby代码添加语法高亮: ```ruby require 'tabbit' @@ -241,7 +248,7 @@ For example, to syntax highlight Ruby code in your Markdown files write: puts table.to_s ``` -This will produce: +效果像下面这样: ```ruby require 'tabbit' @@ -250,24 +257,24 @@ table.add_row('Tim Green', 'tiimgreen@gmail.com') puts table.to_s ``` -GitHub uses [Linguist](https://github.com/github/linguist) to perform language detection and syntax highlighting. You can find out which keywords are valid by perusing the [languages YAML file](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml). +Github使用 [Linguist](https://github.com/github/linguist) 做语言识别和语法高亮。你可以仔细阅读 [languages YAML file](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml),了解有哪些可用的关键字。 -[*Read more about GitHub Flavored Markdown.*](https://help.github.com/articles/github-flavored-markdown) +[*进一步了解 GitHub Flavored Markdown.*](https://help.github.com/articles/github-flavored-markdown) -### Emojis -Emojis can added to on Pull Requests, Issues, commit messages, Markdown files, etc. using `:name_of_emoji:`: +### 使用表情符 + +可以在Pull Requests, Issues, 提交消息, Markdown文件里加入表情符。使用方法`:name_of_emoji:` ``` :smile: ``` - -Would produce: +将输出一个笑脸: :smile: -The full list of supported Emojis on GitHub can be found at [emoji-cheat-sheet.com](http://www.emoji-cheat-sheet.com/) or [scotch-io/All-Github-Emoji-Icons](https://github.com/scotch-io/All-Github-Emoji-Icons). +Github支持的完整表情符号列表详见[emoji-cheat-sheet.com](http://www.emoji-cheat-sheet.com/) 或 [scotch-io/All-Github-Emoji-Icons](https://github.com/scotch-io/All-Github-Emoji-Icons)。 -The top 5 used Ejmojis on GitHub are: +Github上使用最多的5个表情符号是: 1. :shipit: - `:shipit:` 2. :sparkles: - `:sparkles:` @@ -275,8 +282,8 @@ The top 5 used Ejmojis on GitHub are: 4. :+1: - `:+1:` 5. :clap: - `:clap:` -### Images/GIFs -Images and GIFs can be added to comments, READMEs etc.: +### 使用图片/GIF动画 +注释和README等文件里也可以使用图片和GIF动画: ``` ![Alt Text](http://www.sheawong.com/wp-content/uploads/2013/08/keephatin.gif) @@ -284,41 +291,40 @@ Images and GIFs can be added to comments, READMEs etc.: ![Peter don't care](http://www.sheawong.com/wp-content/uploads/2013/08/keephatin.gif) -All images are cached on GitHub, so if your host goes down, the image will remain available. +所有图片都缓存在Gitub,不用担心你的站点不能访问时就看不到图片了。 -#### Embedding Images in GitHub Wiki -There are multiple ways of embedding images in Wiki pages. There's the standard Markdown syntax (shown above). But there's also a syntax that allows things like specifying the height or width of the image: +#### 在Github Wiki里嵌入图片 +有多种方法可以在Wiki页面里嵌入图片。既可以像上一条里那样使用标准的Markdown语法,也可以像下面这样指定图片的高度或宽度: ```markdown [[ http://www.sheawong.com/wp-content/uploads/2013/08/keephatin.gif | height = 100px ]] ``` - -Which produces: +结果: ![Just a screenshot](http://i.imgur.com/J5bMf7S.png) -### Quick Quoting -When on a comment thread and you want to quote something someone previously said, highlight the text and press `r`, this will copy it into your text box in the block-quote format. +### 快速引用文本 +在注释话题里引用之前某个人所说的,只需选中文本,然后按 `r`键,想要的就会以引用的形式复制到你的输入框里。 ![Quick Quote](https://f.cloud.github.com/assets/296432/124483/b0fa6204-6ef0-11e2-83c3-256c37fa7abc.gif) -[*Read more about quick quoting.*](https://github.com/blog/1399-quick-quotes) +[*进一步了解快速引用.*](https://github.com/blog/1399-quick-quotes) -### Quick Licensing -When creating a repository GitHub gives you the options of adding in a pre-made license: +### 快速选择软件许可 +创建一个仓库时,Github会为你提供一个预置的软件许可列表: ![License](http://i.imgur.com/Chqj4Fg.png) -You can also add them to existing repositories by creating a new file through the web interface. When the name `LICENSE` is typed in you will get an option to use a template: +对于已有的仓库,可以通过web界面创建文件来添加软件许可。输入`LICENSE`作为文件名后,同样可以从预置的列表中选择一个作为模板。 ![License](http://i.imgur.com/fTjQict.png) -Also works for `.gitignore`. +这个技巧也使用于 `.gitignore` 文件。 -[*Read more about open source licensing.*](https://help.github.com/articles/open-source-licensing) +[*进一步了解 open source licensing.*](https://help.github.com/articles/open-source-licensing) -### Task Lists -In Issues and Pull requests check boxes can be added with the following syntax (notice the space): +### 任务列表 +Issues和Pull requests里可以添加复选框,语法如下(注意空白符): ``` - [ ] Be awesome @@ -328,7 +334,7 @@ In Issues and Pull requests check boxes can be added with the following syntax ( ![Task List](http://i.imgur.com/k2qZi56.png) -When they are clicked, they will be updated in the pure Markdown: +当项目被选中时,它对应的Markdown源码也被更新了: ``` - [x] Be awesome @@ -336,78 +342,77 @@ When they are clicked, they will be updated in the pure Markdown: - [ ] Sleep ``` -[*Read more about task lists.*](https://github.com/blog/1375%0A-task-lists-in-gfm-issues-pulls-comments) +[*进一步了解任务列表.*](https://github.com/blog/1375%0A-task-lists-in-gfm-issues-pulls-comments) -### Relative Links -Relative links are recommended in your Markdown files when linking to internal content. +### 相对链接 +Markdown文件里链接到内部内容时推荐使用相对链接。 ```markdown [Link to a header](#awesome-section) [Link to a file](docs/readme) ``` +绝对链接会在URL改变时(例如重命名仓库、用户名改变,建立分支项目)被更新。使用相对链接能够保证你的文档不受此影响。 -Absolute links have to be updated whenever the URL changes (e.g. repository renamed, username changed, project forked). Using relative links makes your documentation easily stand on its own. +[*进一步了解相对链接.*](https://help.github.com/articles/relative-links-in-readmes) -[*Read more about relative links.*](https://help.github.com/articles/relative-links-in-readmes) +### GitHub Pages的元数据和插件支持 +在Jekyll页面和文章里,仓库信息可在 `site.github` 命名空间下找到,也可以显示出来,例如,使用 `{{ site.github.project_title }}`显示项目标题。 -### Metadata and Plugin Support for GitHub Pages -Within Jekyll pages and posts, repository information is available within the `site.github` namespace, and can be displayed, for example, using `{{ site.github.project_title }}`. +Jemoji和jekyll-mentions插件为你的Jekyll文章和页面增加了[emoji](#emojis)和[@mentions](https://github.com/blog/821)功能。 -The Jemoji and jekyll-mentions plugins enable [emoji](#emojis) and [@mentions](https://github.com/blog/821) in your Jekyll posts and pages to work just like you'd expect when interacting with a repository on GitHub.com. +[*了解更多 GitHub Pages的元数据和插件支持.*](https://github.com/blog/1797-repository-metadata-and-plugin-support-for-github-pages) -[*Read more about repository metadata and plugin support for GitHub Pages.*](https://github.com/blog/1797-repository-metadata-and-plugin-support-for-github-pages) - -### Viewing YAML Metadata in your Documents -Many blogging websites, like [Jekyll](http://jekyllrb.com/) with [GitHub Pages](http://pages.github.com/), depend on some YAML-formatted metadata at the beginning of your post. GitHub will render this metadata as a horizontal table, for easier reading +### 在文档里查看YAML元数据 +许多博客站点,比如基于[Jekyll](http://jekyllrb.com/)的[GitHub Pages](http://pages.github.com/),都依赖于一些文章头部的YAML格式的元数据。Github会将其渲染成一个水平表格,方便阅读。 ![YAML metadata](https://camo.githubusercontent.com/47245aa16728e242f74a9a324ce0d24c0b916075/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f36343035302f313232383236372f65303439643063362d323761302d313165332d396464382d6131636432323539393334342e706e67) -[*Read more about viewing YAML metadata in your documents.*](https://github.com/blog/1647-viewing-yaml-metadata-in-your-documents) +[*进一步了解 在文档里查看YAML元数据.*](https://github.com/blog/1647-viewing-yaml-metadata-in-your-documents) -### Rendering Tabular Data -GitHub supports rendering tabular data in the form of `.csv` (comma-separated) and `.tsv` (tab-separated) files. +### 渲染表格数据 + +GitHub支持将 `.csv` (comma分隔)和`.tsv` (tab分隔)格式的文件渲染成表格数据。 ![Tabular data](https://camo.githubusercontent.com/1b6dd0157ffb45d9939abf14233a0cb13b3b4dfe/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f3238323735392f3937363436322f33323038336463652d303638642d313165332d393262322d3566323863313061353035392e706e67) -[*Read more about rendering tabular data.*](https://github.com/blog/1601-see-your-csvs) +[*进一步了解渲染表格数据.*](https://github.com/blog/1601-see-your-csvs) ### Diffs -#### Rendered Prose Diffs -Commits and pull requests including rendered documents supported by GitHub (e.g. Markdown) feature *source* and *rendered* views. +#### 可渲染纯文本Diff + +提交和Pull Requests里包含有Github支持的可渲染文档(比如Markdown)会提供*source* 和 *rendered* 两个视图功能。 ![Source / Rendered view](https://github-images.s3.amazonaws.com/help/repository/rendered_prose_diff.png) -Click the "rendered" button to see the changes as they'll appear in the rendered document. Rendered prose view is handy when you're adding, removing, and editing text: +点击 "rendered" 按钮,看看改动在渲染后的显示效果。当你添加、删除或修改文本时,渲染纯文本视图非常方便。 ![Rendered Prose Diffs](https://f.cloud.github.com/assets/17715/2003056/3997edb4-862b-11e3-90be-5e9586edecd7.png) -[*Read more about rendered prose diffs.*](https://github.com/blog/1784-rendered-prose-diffs) +[*进一步了解渲染纯文本视图Diffs.*](https://github.com/blog/1784-rendered-prose-diffs) -#### Diffable Maps -Any time you view a commit or pull request on GitHub that includes geodata, GitHub will render a visual representation of what was changed. +#### 可比较地图 +当你在GitHub上查看一个包含地理数据的提交或pull request时,Github可以显示数据变动的视觉表示。 [![Diffable Maps](https://f.cloud.github.com/assets/282759/2090660/63f2e45a-8e97-11e3-9d8b-d4c8078b004e.gif)](https://github.com/benbalter/congressional-districts/commit/2233c76ca5bb059582d796f053775d8859198ec5) -[*Read more about diffable maps.*](https://github.com/blog/1772-diffable-more-customizable-maps) +[*进一步了解可比较地图.*](https://github.com/blog/1772-diffable-more-customizable-maps) -#### Expanding Context in Diffs -Using the *unfold* button in the gutter of a diff, you can reveal additional lines of context with a click. You can keep clicking *unfold* until you've revealed the whole file, and the feature is available anywhere GitHub renders diffs. +#### 扩展Diff上下文 [ Expanding Context in Diffs ] +你可以通过点击diff边栏里的 *unfold* 按钮来多显示几行上下文。你可以一直点击 *unfold* 按钮直到显示了文件的全部内容。这个功能在所有GitHub产生的diff界面都可以使用。 ![Expanding Context in Diffs](https://f.cloud.github.com/assets/22635/1610539/863c1f64-5584-11e3-82bf-151b406a272f.gif) -[*Read more about expanding context in diffs.*](https://github.com/blog/1705-expanding-context-in-diffs) +[*进一步了解扩展Diff上下文.*](https://github.com/blog/1705-expanding-context-in-diffs) -#### Diff or Patch of Pull Request -You can get the diff of a Pull Request by adding a `.diff` or `.patch` -extension to the end of the URL. For example: +#### Pull Request的Diff或Patch +在Pull Request的URL后面加上 `.diff` 或 `.patch` 的扩展名就可以得到它的diff或patch文件,例如: ``` https://github.com/tiimgreen/github-cheat-sheet/pull/15 https://github.com/tiimgreen/github-cheat-sheet/pull/15.diff https://github.com/tiimgreen/github-cheat-sheet/pull/15.patch ``` - -The `.diff` extension would give you this in plain text: +`.diff` 扩展会使用普通文本格式显示如下内容: ``` diff --git a/README.md b/README.md @@ -429,33 +434,34 @@ index 88fcf69..8614873 100644 ``` ### Hub -[Hub](https://github.com/github/hub) is a command line Git wrapper that gives you extra features and commands that make working with GitHub easier. +[Hub](https://github.com/github/hub)是一个对Git进行了封装的命令行工具,可以帮助你更方便的使用Github。 -This allows you to do things like: +这使得你可以像下面这样进行克隆: ```bash $ hub clone tiimgreen/toc ``` -[*Check out some more cool commands Hub has to offer.*](https://github.com/github/hub#commands) +[*查看更多Hub提供的超酷命令.*](https://github.com/github/hub#commands) -### Decreasing Contributor Friction -If you want people to use and contribute to your project, you need to start by answering their most basic questions. What does the project do? How do I use it? How am I allowed to use it? How do I contribute? How do I get up and running in development? How do I make sure my new features didn't break old functionality? +### 减少贡献者冲突 +假设你想人们使用你的项目并给你的项目做出贡献,你往往需要回答他们常见问题。这个项目是干什么用的?我如何使用它?允许我怎样使用?我如何为项目出力?我怎样配置开发环境?我怎么能保证新功能不会破坏已有的功能? -[Friction](https://github.com/rafalchmiel/friction) is a command line script that will check your project for common [answers to these questions](https://github.com/rafalchmiel/friction/wiki). This is some example output: +[Friction](https://github.com/rafalchmiel/friction)是一个命令行脚本,用来检查你的项目是否[回答了这些问题](https://github.com/rafalchmiel/friction/wiki)。下面是示例输出: [![Friction output](http://i.imgur.com/4EgpWo4.png)](https://github.com/rafalchmiel/friction) -*Friction supports MRI 2.1.0, MRI 2.0.0, and MRI 1.9.3.* +*Friction 支持 MRI 2.1.0, MRI 2.0.0 和 MRI 1.9.3.* -### Contributing Guidelines -Adding a `CONTRIBUTING` file to the root of your repository will add a link to your file when a contributor creates an Issue or opens a Pull Request. +### 贡献者指南 + +在你的仓库的根目录添加一个名为 `CONTRIBUTING` 的文件后,贡献者在新建Issue或Pull Request时会看到这个文件的链接。 ![Contributing Guidelines](https://camo.githubusercontent.com/71995d6b0e620a9ef1ded00a04498241c69dd1bf/68747470733a2f2f6769746875622d696d616765732e73332e616d617a6f6e6177732e636f6d2f736b697463682f6973737565732d32303132303931332d3136323533392e6a7067) -[*Read more about contributing guidelines.*](https://github.com/blog/1184-contributing-guidelines) +[*进一步了解贡献者指南.*](https://github.com/blog/1184-contributing-guidelines) -### GitHub Resources +### GitHub参考资源 | Title | Link | | ----- | ---- | | GitHub Explore | https://github.com/explore | @@ -464,7 +470,7 @@ Adding a `CONTRIBUTING` file to the root of your repository will add a link to y | GitHub Training | http://training.github.com/ | | GitHub Developer | https://developer.github.com/ | -#### GitHub Talks +#### Github演讲 | Title | Link | | ----- | ---- | | How GitHub Uses GitHub to Build GitHub | https://www.youtube.com/watch?v=qyz3jkOBbQY | @@ -473,9 +479,9 @@ Adding a `CONTRIBUTING` file to the root of your repository will add a link to y | Git and GitHub Secrets | https://www.youtube.com/watch?v=Foz9yvMkvlA | | More Git and GitHub Secrets | https://www.youtube.com/watch?v=p50xsL-iVgU | -## Git -### Previous Branch -To move to the previous branch in Git: +## Git篇 +### 上一个分支 +快速检出上一个分支: ```bash $ git checkout - @@ -488,50 +494,50 @@ $ git checkout - # Switched to branch 'master' ``` -[*Read more about Git branching.*](http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging) +[*进一步了解 Git 分支.*](http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging) -### Stripspace +### 去除文件里的空白 -Git Stripspace: +Git Stripspace命令可以: -- Strips trailing whitespace -- Collapses newlines -- Adds newline to end of file +- 去掉行尾空白符 +- 多个空行压缩成一行 +- 必要时在文件末尾增加一个空行 + +使用此命令时必须传入一个文件,像这样: -A file must be passed when calling the command, e.g.: ```bash $ git stripspace < README.md ``` -[*Read more about the Git `stripspace` command.*](http://git-scm.com/docs/git-stripspace) +[*进一步了解 Git `stripspace` 命令.*](http://git-scm.com/docs/git-stripspace) -### Checking out Pull Requests -If you want to check out pull request locally, you can fetch it using that command: +### 检出Pull Requests +如果想检出pull requests到本地,可以先用下面的fetch命令: ```bash $ git fetch origin '+refs/pull/*/head:refs/pull/*' ``` -then, checkout Pull Request (i.e. 42) using +然后用checkout命令检查想要的Pull Request(比如42) ```bash $ git checkout refs/pull/42 ``` -Alternatively, you can fetch them as remote branches: +你也可以把它们当作远程分支来fetch: ```bash $ git fetch origin '+refs/pull/*/head:refs/remotes/origin/pr/*' ``` -and checkout as: +然后这样检出: ```bash $ git checkout origin/pr/42 ``` -and even fetch them automatically, if you add corresponding lines in your .git/config: - +或者干脆在你的.git/config文件里添加如下内容,这样就可以自动获取它们了。 ``` [remote "origin"] @@ -546,117 +552,117 @@ and even fetch them automatically, if you add corresponding lines in your .git/c fetch = +refs/pull/*/head:refs/remotes/origin/pr/* ``` -[*Read more about checking out pull requests locally.*](https://help.github.com/articles/checking-out-pull-requests-locally) +[*进一步了解如何检出pull request到本地.*](https://help.github.com/articles/checking-out-pull-requests-locally) -### Empty Commits :trollface: -Commits can be pushed with no code changes by adding `--allow-empty`: +### 空提交 :trollface: +可以使用`--allow-empty`选项强制创建一个没有任何改动的提交: ```bash $ git commit -m "Big-ass commit" --allow-empty ``` -Some use-cases for this (that make sense), include: +这样做在如下几种情况下是有意义的: - - Annotating the start of a new bulk of work or a new feature. - - Documenting when you make changes to the project that aren't code related. - - Communicating with people using your repository. - - The first commit of a repo, as the first commit cannot be rebased later: `git commit -m "init repo" --allow-empty`. + - 标记一批工作或一个新功能的开始。 + - 记录你对项目进行了跟代码无关的改动。 + - 跟使用你仓库的其他人交流。 + - 作为仓库的第一次提交,因为第一次提交日后是不能被rebase的: `git commit -m "init repo" --allow-empty`. -### Styled Git Status -Running: +### 给Git Status命令加样式 +在命令行输入如下命令: ```bash $ git status ``` -Produces: +可以看到: ![git status](http://i.imgur.com/o3PEHAA.png) -By adding `-sb`: +加上`-sb`选项: ```bash $ git status -sb ``` -This is produced: +这回得到: ![git status -sb](http://i.imgur.com/xNI1bT0.png) -[*Read more about the Git `status` command.*](http://git-scm.com/docs/git-status) +[*进一步了解 Git `status` 命令.*](http://git-scm.com/docs/git-status) -### Styled Git Log -Running: +### 给Git Log命令加样式 +输入如下命令: ```bash $ git log --all --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative ``` -Produces: +可以看到: ![git log --all --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative](http://i.imgur.com/R2z8l7c.png) -Credit to [Palesz](http://stackoverflow.com/users/88355/palesz) +这要归功于[Palesz](http://stackoverflow.com/users/88355/palesz)在stackoverflow的回答。 -*This can be aliased using the instructions found [here](https://github.com/tiimgreen/github-cheat-sheet#aliases).* +*这个命令可以被用作别名,详细做法见[这里](https://github.com/tiimgreen/github-cheat-sheet#aliases)。* -[*Read more about the Git `log` command.*](http://git-scm.com/docs/git-log) +[*进一步了解 Git `log` 命令.*](http://git-scm.com/docs/git-log) -### Git Query -A Git query allows you to search all your previous commit messages and find the most recent one matching the query. +### Git查询 +Git查询运行你在之前的所有提交信息里进行搜索,找到其中和搜索条件相匹配的最近的一条。 ```bash $ git show :/query ``` -Where `query` (case-sensitive) is the term you want to search, this then finds the last one and gives details on the lines that were changed. +这里 `query` (区别大小写)是你想要搜索的词语, 这条命令会找到包含这个词语的最后那个提交并显示变动详情。 ```bash $ git show :/typo ``` ![git show :/query](http://i.imgur.com/icaGiNt.png) -*Press `q` to quit.* +* 按 `q` 键退出命令。* -### Merged Branches -Running: +### 已合并的分支 +输入命令: ```bash $ git branch --merged ``` -Will give you a list of all branches that have been merged into your current branch. +这会显示所有已经合并到你当前分支的分支列表。 -Conversely: +相反地: ```bash $ git branch --no-merged ``` -Will give you a list of branches that have not been merged into your current branch. +会显示所有还没有合并到你当前分支的分支列表。 -[*Read more about the Git `branch` command.*](http://git-scm.com/docs/git-branch) +[*进一步了解 Git `branch` 命令.*](http://git-scm.com/docs/git-branch) -### Web Server for Browsing Local Repositories -Use the Git `instaweb` command to instantly browse your working repository in `gitweb`. This command is a simple script to set up `gitweb` and a web server for browsing the local repository. +### 用来浏览本地仓库的web服务器 +使用Git的 `instaweb` 可以立即在 `gitweb`中浏览你的工作仓库。这个命令是个简单的脚步,配置了`gitweb`和用来浏览本地仓库的Web服务器。*(译者注:默认需要lighttpd支持)* ```bash $ git instaweb ``` -Opens: +执行后打开: ![Git instaweb](http://i.imgur.com/Dxekmqc.png) -[*Read more about the Git `instaweb` command.*](http://git-scm.com/docs/git-instaweb) +[*进一步了解 Git `instaweb` 命令.*](http://git-scm.com/docs/git-instaweb) -### Git Configurations -Your `.gitconfig` file contains all your Git configurations. +### Git配置 +所有Git配置都保存在你的`.gitconfig` 文件中。 -#### Aliases -Aliases are helpers that let you define your own git calls. For example you could set `git a` to run `git add --all`. +#### 别名 [ Aliases ] +别名用来帮助你定义自己的git命令。比如你可以定义 `git a` 来运行 `git add --all`。 -To add an alias, either navigate to `~/.gitconfig` and fill it out in the following format: +要添加一个别名, 一种方法是打开 `~/.gitconfig` 文件并添加如下内容: ``` [alias] @@ -669,27 +675,27 @@ To add an alias, either navigate to `~/.gitconfig` and fill it out in the follow remotes = remote -v ``` -...or type in the command-line: +...或者在命令行里键入: ```bash $ git config --global alias.new_alias git_function ``` -For example: +例如: ```bash $ git config --global alias.cm commit ``` -For an alias with multiple functions use quotes: +指向多个命令的别名可以用引号来定义: ```bash $ git config --global alias.ac 'add -A . && commit' ``` -Some useful aliases include: +下面列出了一些有用的别名: -| Alias | Command | What to Type | +| 别名 Alias | 命令 Command | 如何设置 What to Type | | --- | --- | --- | | `git cm` | `git commit` | `git config --global alias.cm commit` | | `git co` | `git checkout` | `git config --global alias.co checkout` | @@ -699,8 +705,8 @@ Some useful aliases include: | `git branches` | `git branch -a` | `git config --global alias.branches 'branch -a'` | | `git remotes` | `git remote -v` | `git config --global alias.remotes 'remote -v'` | -#### Auto-Correct -If you type `git comit` you will get this: +#### 自动纠错 +如果键入 `git comit` 你会看到如下输出: ```bash $ git comit -m "Message" @@ -710,13 +716,13 @@ $ git comit -m "Message" # commit ``` -To call `commit` when `comit` is typed, just enable auto-correct: +为了在键入 `comit` 调用 `commit`命令,只需启用自动纠错功能: ```bash $ git config --global help.autocorrect 1 ``` -So now you will get this: +现在你就会看到: ```bash $ git comit -m "Message" @@ -725,16 +731,16 @@ $ git comit -m "Message" # in 0.1 seconds automatically... ``` -#### Color -To add more color to your Git output: +#### 颜色 +要在你的Git命令输出里加上颜色的话,可以用如下命令: ```bash $ git config --global color.ui 1 ``` -[*Read more about the Git `config` command.*](http://git-scm.com/docs/git-config) +[*进一步了解 Git `config` 命令.*](http://git-scm.com/docs/git-config) -### Git Resources +### Git参考资源 | Title | Link | | ----- | ---- | | Official Git Site | http://git-scm.com/ | @@ -749,7 +755,7 @@ $ git config --global color.ui 1 | Git for Computer Scientists | http://eagain.net/articles/git-for-computer-scientists/ | | Git Magic | http://www-cs-students.stanford.edu/~blynn/gitmagic/ | -#### Git Books +#### Git书籍 | Title | Link | | ----- | ---- | | Pragmatic Version Control Using Git | http://www.pragprog.com/titles/tsgit/pragmatic-version-control-using-git | From 550e91316a30ce524ebd738b95a0e3b5d867e604 Mon Sep 17 00:00:00 2001 From: wolfg1969 Date: Wed, 30 Apr 2014 09:19:58 +0800 Subject: [PATCH 3/4] fix relative links --- README.zh-cn.md | 188 ++++++++++++++++++++++++------------------------ 1 file changed, 94 insertions(+), 94 deletions(-) diff --git a/README.zh-cn.md b/README.zh-cn.md index dad5fdd..554caba 100644 --- a/README.zh-cn.md +++ b/README.zh-cn.md @@ -3,61 +3,61 @@ *Read this in other languages: [English](README.md), [한국어](README.ko.md), [日本語](README.ja.md), [简体中文](README.zh-cn.md).* -## Table of Contents - - [GitHub篇](#github) - - [忽略空白字符](#ignore-whitespace) - - [调整缩进宽度](#adjust-tab-space) - - [查看某个用户的提交历史](#commit-history-by-author) - - [克隆仓库](#cloning-a-repository) - - [比较分支](#comparing-branches) - - [派生仓库之间比较分支](#compare-branches-across-forked-repositories) +# 目录 + - [GitHub](#github) + - [Ignore Whitespace](#ignore-whitespace) + - [Adjust Tab Space](#adjust-tab-space) + - [Commit History by Author](#commit-history-by-author) + - [Cloning a Repository](#cloning-a-repository) + - [Comparing Branches](#comparing-branches) + - [Compare Branches across Forked Repositories](#compare-branches-across-forked-repositories) - [Gists](#gists) - [Git.io](#gitio) - - [快捷键](#keyboard-shortcuts) - - [高亮显示一行或多行代码](#line-highlighting-in-repositories) - - [通过提交信息关闭Issue](#closing-issues-via-commit-messages) - - [链接Issue](#cross-link-issues) - - [Pull Requests的CI结果](#ci-status-on-pull-requests) - - [在Markdown文件中使用语法高亮](#syntax-highlighting-in-markdown-files) - - [表情符号](#emojis) - - [图片/GIF动画](#imagesgifs) - - [在Github Wiki里嵌入图片](#embedding-images-in-github-wiki) - - [快速引用文本](#quick-quoting) - - [快速选择软件许可](#quick-licensing) - - [任务列表](#task-lists) - - [相对链接](#relative-links) - - [GitHub Pages的元数据和插件支持](#metadata-and-plugin-support-for-github-pages) - - [在文档里查看YAML元数据](#viewing-yaml-metadata-in-your-documents) - - [渲染表格数据](#rendering-tabular-data) + - [Keyboard Shortcuts](#keyboard-shortcuts) + - [Line Highlighting in Repositories](#line-highlighting-in-repositories) + - [Closing Issues via Commit Messages](#closing-issues-via-commit-messages) + - [Cross-Link Issues](#cross-link-issues) + - [CI Status on Pull Requests](#ci-status-on-pull-requests) + - [Syntax Highlighting in Markdown Files](#syntax-highlighting-in-markdown-files) + - [Emojis](#emojis) + - [Images/GIFs](#imagesgifs) + - [Embedding Images in GitHub Wiki](#embedding-images-in-github-wiki) + - [Quick Quoting](#quick-quoting) + - [Quick Licensing](#quick-licensing) + - [Task Lists](#task-lists) + - [Relative Links](#relative-links) + - [Metadata and Plugin Support for GitHub Pages](#metadata-and-plugin-support-for-github-pages) + - [Viewing YAML Metadata in your Documents](#viewing-yaml-metadata-in-your-documents) + - [Rendering Tabular Data](#rendering-tabular-data) - [Diffs](#diffs) - - [渲染单调的Diff](#rendered-prose-diffs) - - [可比较地图](#diffable-maps) - - [扩展Diff上下文](#expanding-context-in-diffs) - - [Pull Request的Diff或Patch](#diff-or-patch-of-pull-request) + - [Rendered prose Diffs](#rendered-prose-diffs) + - [Diffable Maps](#diffable-maps) + - [Expanding Context in Diffs](#expanding-context-in-diffs) + - [Diff or Patch of Pull Request](#diff-or-patch-of-pull-request) - [Hub](#hub) - - [减少贡献者冲突](#decreasing-contributor-friction) - - [贡献者指南](#contributing-guidelines) - - [GitHub 参考资源](#github-resources) + - [Decreasing Contributor Friction](#decreasing-contributor-friction) + - [Contributing Guidelines](#contributing-guidelines) + - [GitHub Resources](#github-resources) - [GitHub Talks](#github-talks) - - [Git篇](#git) - - [上个分支](#previous-branch) - - [去除空白](#stripspace) - - [检出 Pull Requests](#checking-out-pull-requests) - - [空提交 :trollface:](#empty-commits-trollface) - - [给 Git Status 命令加样式](#styled-git-status) - - [给 Git Log 命令加样式](#styled-git-log) - - [Git 查询](#git-query) - - [已合并的分支](#merged-branches) - - [用于浏览本地参考的Web服务器](#web-server-for-browsing-local-repositories) - - [Git 配置](#git-configurations) - - [别名](#aliases) - - [自动纠错](#auto-correct) - - [颜色](#color) - - [Git 参考资源](#git-resources) - - [Git 书籍](#git-books) + - [Git](#git) + - [Previous Branch](#previous-branch) + - [Stripspace](#stripspace) + - [Checking out Pull Requests](#checking-out-pull-requests) + - [Empty Commits :trollface:](#empty-commits-trollface) + - [Styled Git Status](#styled-git-status) + - [Styled Git Log](#styled-git-log) + - [Git Query](#git-query) + - [Merged Branches](#merged-branches) + - [Web Server for Browsing Local Repositories](#web-server-for-browsing-local-repositories) + - [Git Configurations](#git-configurations) + - [Aliases](#aliases) + - [Auto-Correct](#auto-correct) + - [Color](#color) + - [Git Resources](#git-resources) + - [Git Books](#git-books) -## GitHub篇 -### 忽略空白字符 +## GitHub +### Ignore Whitespace 在任意diff页面的URL后加上`?w=1`,可以去掉那些只是空白字符的变化,使你能更专注于代码的变化。 @@ -65,7 +65,7 @@ [*详见 GitHub secrets.*](https://github.com/blog/967-github-secrets) -### 调整缩进宽度 +### Adjust Tab Space 在diff或者file页面的URL后面加上`?ts=4`,这样当显示tab字符的长度时就会是4个空格的长度,不再是默认的8个空格。`ts`后面的数字还可以根据你个人的偏好进行修改。不过,这个小诀窍在Gists页面和raw file页面不起作用。 下面是我们在Go语言的source file页面URL后加`?ts=4`[前](https://github.com/pengwynn/flint/blob/master/flint/flint.go)的例子: @@ -76,7 +76,7 @@ ![After, tab space example](http://i.imgur.com/70FL4H9.png) -### 查看某个用户的提交历史 +### Commit History by Author 查看某个用户的所有提交历史,只需在commits页面URL后加上`?author=username`。 ``` @@ -87,7 +87,7 @@ https://github.com/rails/rails/commits/master?author=dhh [*深入了解提交视图之间的区别*](https://help.github.com/articles/differences-between-commit-views) -### 克隆仓库 +### Cloning Repository 当我们克隆某一资源时,可以不要那个`.git`后缀。 ```bash @@ -96,7 +96,7 @@ $ git clone https://github.com/tiimgreen/github-cheat-sheet [*更多对 Git `clone` 命令的介绍.*](http://git-scm.com/docs/git-clone) -### 比较分支 +### Comparing Branches 如果我们想要比较两个分支,可以像下面一样修改URL: @@ -129,7 +129,7 @@ https://github.com/rails/rails/compare/master@{2014-10-04}...master [*了解更多关于比较跨时间段的提交记录.*](https://help.github.com/articles/comparing-commits-across-time) -### 派生仓库之间比较分支 +### Compare Branches across Forked Repositories 想要对派生仓库Forked Repository)之间的分支进行比较,可以像下面这样修改URL实现: @@ -182,7 +182,7 @@ Location: https://github.com/... [*进一步了解 Git.io.*](https://github.com/blog/985-git-io-github-url-shortener) -### 快捷键 +### Keyboard Shortcuts 在仓库主页上提供了快捷键方便快速导航。 @@ -198,7 +198,7 @@ Location: https://github.com/... [*进一步了解如何使用 Command Bar.*](https://help.github.com/articles/using-the-command-bar) -### 高亮显示一行或多行代码 +### Line Highlighting in Repositories 在代码文件地址后加上`#L52`或者单击行号52都会将第52行代码高亮显示。 @@ -210,7 +210,7 @@ https://github.com/rails/rails/blob/master/activemodel/lib/active_model.rb#L53-L ![Line Highlighting](http://i.imgur.com/8AhjrCz.png) -### 通过提交信息关闭Issue +### Closing Issues via Commit Messages 如果某个提交修复了一个Issue,当提交到master分支时,提交信息里可以使用`fix/fixes/fixed`, `close/closes/closed` 或者 `resolve/resolves/resolved`等关键词,后面再跟上Issue号,这样就会关闭这个Issue。 @@ -224,21 +224,21 @@ $ git commit -m "Fix screwup, fixes #12" [*进一步了解通过提交信息关闭Issue.*](https://help.github.com/articles/closing-issues-via-commit-messages) -### 引用Issue +### Cross-Link Issues 如果你想引用到同一个仓库中的一个Issue,只需使用井号 `#` 加上Issue号,这样就会自动创建到此Issue的链接。 要链接到其他仓库的Issue,就使用`user_name/repo_name#ISSUE_NUMBER`的方式,例如`tiimgreen/toc#12`。 ![Cross-Link Issues](https://camo.githubusercontent.com/447e39ab8d96b553cadc8d31799100190df230a8/68747470733a2f2f6769746875622d696d616765732e73332e616d617a6f6e6177732e636f6d2f626c6f672f323031312f736563726574732f7265666572656e6365732e706e67) -### Pull Requests的CI结果 +### CI Status on Pull Requests 如果配置正确,[Travis CI](https://travis-ci.org/)会为每个你收到的Pull Request执行构建,就像每次提交也会触发构建一样。想了解更多关于Travis CI的信息,请看 [Travis CI入门](http://docs.travis-ci.com/user/getting-started/)。 [![Travic CI status](https://cloud.githubusercontent.com/assets/1687642/2700187/3a88838c-c410-11e3-9a46-e65e2a0458cd.png)](https://github.com/octokit/octokit.rb/pull/452) [*进一步了解 Commit status API.*](https://github.com/blog/1227-commit-status-api) -### 在Markdown文件中使用语法高亮 +### Syntax Highlighting in Markdown Files 例如,可以像下面这样在你的Markdown文件里为Ruby代码添加语法高亮: ```ruby @@ -261,7 +261,7 @@ Github使用 [Linguist](https://github.com/github/linguist) 做语言识别和 [*进一步了解 GitHub Flavored Markdown.*](https://help.github.com/articles/github-flavored-markdown) -### 使用表情符 +### Emojis 可以在Pull Requests, Issues, 提交消息, Markdown文件里加入表情符。使用方法`:name_of_emoji:` @@ -282,7 +282,7 @@ Github上使用最多的5个表情符号是: 4. :+1: - `:+1:` 5. :clap: - `:clap:` -### 使用图片/GIF动画 +### Images/GIFS 注释和README等文件里也可以使用图片和GIF动画: ``` @@ -293,7 +293,7 @@ Github上使用最多的5个表情符号是: 所有图片都缓存在Gitub,不用担心你的站点不能访问时就看不到图片了。 -#### 在Github Wiki里嵌入图片 +#### Embedding Images in GitHub Wiki 有多种方法可以在Wiki页面里嵌入图片。既可以像上一条里那样使用标准的Markdown语法,也可以像下面这样指定图片的高度或宽度: ```markdown @@ -303,14 +303,14 @@ Github上使用最多的5个表情符号是: ![Just a screenshot](http://i.imgur.com/J5bMf7S.png) -### 快速引用文本 +### Quick Quoting 在注释话题里引用之前某个人所说的,只需选中文本,然后按 `r`键,想要的就会以引用的形式复制到你的输入框里。 ![Quick Quote](https://f.cloud.github.com/assets/296432/124483/b0fa6204-6ef0-11e2-83c3-256c37fa7abc.gif) [*进一步了解快速引用.*](https://github.com/blog/1399-quick-quotes) -### 快速选择软件许可 +### Quick Licensing 创建一个仓库时,Github会为你提供一个预置的软件许可列表: ![License](http://i.imgur.com/Chqj4Fg.png) @@ -323,7 +323,7 @@ Github上使用最多的5个表情符号是: [*进一步了解 open source licensing.*](https://help.github.com/articles/open-source-licensing) -### 任务列表 +### Task Lists Issues和Pull requests里可以添加复选框,语法如下(注意空白符): ``` @@ -344,7 +344,7 @@ Issues和Pull requests里可以添加复选框,语法如下(注意空白符 [*进一步了解任务列表.*](https://github.com/blog/1375%0A-task-lists-in-gfm-issues-pulls-comments) -### 相对链接 +### Relative Links Markdown文件里链接到内部内容时推荐使用相对链接。 ```markdown @@ -355,21 +355,21 @@ Markdown文件里链接到内部内容时推荐使用相对链接。 [*进一步了解相对链接.*](https://help.github.com/articles/relative-links-in-readmes) -### GitHub Pages的元数据和插件支持 +### Metadata and Plugin Support for GitHub Pages 在Jekyll页面和文章里,仓库信息可在 `site.github` 命名空间下找到,也可以显示出来,例如,使用 `{{ site.github.project_title }}`显示项目标题。 Jemoji和jekyll-mentions插件为你的Jekyll文章和页面增加了[emoji](#emojis)和[@mentions](https://github.com/blog/821)功能。 [*了解更多 GitHub Pages的元数据和插件支持.*](https://github.com/blog/1797-repository-metadata-and-plugin-support-for-github-pages) -### 在文档里查看YAML元数据 +### Viewing YAML Metadata in your Documents 许多博客站点,比如基于[Jekyll](http://jekyllrb.com/)的[GitHub Pages](http://pages.github.com/),都依赖于一些文章头部的YAML格式的元数据。Github会将其渲染成一个水平表格,方便阅读。 ![YAML metadata](https://camo.githubusercontent.com/47245aa16728e242f74a9a324ce0d24c0b916075/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f36343035302f313232383236372f65303439643063362d323761302d313165332d396464382d6131636432323539393334342e706e67) [*进一步了解 在文档里查看YAML元数据.*](https://github.com/blog/1647-viewing-yaml-metadata-in-your-documents) -### 渲染表格数据 +### Rendering Tabular Data GitHub支持将 `.csv` (comma分隔)和`.tsv` (tab分隔)格式的文件渲染成表格数据。 @@ -378,7 +378,7 @@ GitHub支持将 `.csv` (comma分隔)和`.tsv` (tab分隔)格式的文件渲染 [*进一步了解渲染表格数据.*](https://github.com/blog/1601-see-your-csvs) ### Diffs -#### 可渲染纯文本Diff +#### Rendered prose Diffs 提交和Pull Requests里包含有Github支持的可渲染文档(比如Markdown)会提供*source* 和 *rendered* 两个视图功能。 @@ -390,21 +390,21 @@ GitHub支持将 `.csv` (comma分隔)和`.tsv` (tab分隔)格式的文件渲染 [*进一步了解渲染纯文本视图Diffs.*](https://github.com/blog/1784-rendered-prose-diffs) -#### 可比较地图 +#### Diffable Maps 当你在GitHub上查看一个包含地理数据的提交或pull request时,Github可以显示数据变动的视觉表示。 [![Diffable Maps](https://f.cloud.github.com/assets/282759/2090660/63f2e45a-8e97-11e3-9d8b-d4c8078b004e.gif)](https://github.com/benbalter/congressional-districts/commit/2233c76ca5bb059582d796f053775d8859198ec5) [*进一步了解可比较地图.*](https://github.com/blog/1772-diffable-more-customizable-maps) -#### 扩展Diff上下文 [ Expanding Context in Diffs ] +#### Expanding Context in Diffs 你可以通过点击diff边栏里的 *unfold* 按钮来多显示几行上下文。你可以一直点击 *unfold* 按钮直到显示了文件的全部内容。这个功能在所有GitHub产生的diff界面都可以使用。 ![Expanding Context in Diffs](https://f.cloud.github.com/assets/22635/1610539/863c1f64-5584-11e3-82bf-151b406a272f.gif) [*进一步了解扩展Diff上下文.*](https://github.com/blog/1705-expanding-context-in-diffs) -#### Pull Request的Diff或Patch +#### Diff or Patch of Pull Request 在Pull Request的URL后面加上 `.diff` 或 `.patch` 的扩展名就可以得到它的diff或patch文件,例如: ``` @@ -444,7 +444,7 @@ $ hub clone tiimgreen/toc [*查看更多Hub提供的超酷命令.*](https://github.com/github/hub#commands) -### 减少贡献者冲突 +### Decreasing Contributor Friction 假设你想人们使用你的项目并给你的项目做出贡献,你往往需要回答他们常见问题。这个项目是干什么用的?我如何使用它?允许我怎样使用?我如何为项目出力?我怎样配置开发环境?我怎么能保证新功能不会破坏已有的功能? [Friction](https://github.com/rafalchmiel/friction)是一个命令行脚本,用来检查你的项目是否[回答了这些问题](https://github.com/rafalchmiel/friction/wiki)。下面是示例输出: @@ -453,7 +453,7 @@ $ hub clone tiimgreen/toc *Friction 支持 MRI 2.1.0, MRI 2.0.0 和 MRI 1.9.3.* -### 贡献者指南 +### Contributing Guidelines 在你的仓库的根目录添加一个名为 `CONTRIBUTING` 的文件后,贡献者在新建Issue或Pull Request时会看到这个文件的链接。 @@ -461,7 +461,7 @@ $ hub clone tiimgreen/toc [*进一步了解贡献者指南.*](https://github.com/blog/1184-contributing-guidelines) -### GitHub参考资源 +### GitHub Resources | Title | Link | | ----- | ---- | | GitHub Explore | https://github.com/explore | @@ -470,7 +470,7 @@ $ hub clone tiimgreen/toc | GitHub Training | http://training.github.com/ | | GitHub Developer | https://developer.github.com/ | -#### Github演讲 +#### Github Talks | Title | Link | | ----- | ---- | | How GitHub Uses GitHub to Build GitHub | https://www.youtube.com/watch?v=qyz3jkOBbQY | @@ -479,8 +479,8 @@ $ hub clone tiimgreen/toc | Git and GitHub Secrets | https://www.youtube.com/watch?v=Foz9yvMkvlA | | More Git and GitHub Secrets | https://www.youtube.com/watch?v=p50xsL-iVgU | -## Git篇 -### 上一个分支 +## Git +### Previous Branch 快速检出上一个分支: ```bash @@ -496,7 +496,7 @@ $ git checkout - [*进一步了解 Git 分支.*](http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging) -### 去除文件里的空白 +### Stripspace Git Stripspace命令可以: @@ -512,7 +512,7 @@ $ git stripspace < README.md [*进一步了解 Git `stripspace` 命令.*](http://git-scm.com/docs/git-stripspace) -### 检出Pull Requests +### Checking out Pull Requests 如果想检出pull requests到本地,可以先用下面的fetch命令: ```bash @@ -554,7 +554,7 @@ $ git checkout origin/pr/42 [*进一步了解如何检出pull request到本地.*](https://help.github.com/articles/checking-out-pull-requests-locally) -### 空提交 :trollface: +### Empty Commits :trollface: 可以使用`--allow-empty`选项强制创建一个没有任何改动的提交: ```bash @@ -568,7 +568,7 @@ $ git commit -m "Big-ass commit" --allow-empty - 跟使用你仓库的其他人交流。 - 作为仓库的第一次提交,因为第一次提交日后是不能被rebase的: `git commit -m "init repo" --allow-empty`. -### 给Git Status命令加样式 +### Styled Git Status 在命令行输入如下命令: ```bash @@ -591,7 +591,7 @@ $ git status -sb [*进一步了解 Git `status` 命令.*](http://git-scm.com/docs/git-status) -### 给Git Log命令加样式 +### Styled Git Log 输入如下命令: ```bash @@ -608,7 +608,7 @@ $ git log --all --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s [*进一步了解 Git `log` 命令.*](http://git-scm.com/docs/git-log) -### Git查询 +### Git Query Git查询运行你在之前的所有提交信息里进行搜索,找到其中和搜索条件相匹配的最近的一条。 ```bash @@ -624,7 +624,7 @@ $ git show :/typo * 按 `q` 键退出命令。* -### 已合并的分支 +### Merged Branches 输入命令: ```bash @@ -643,7 +643,7 @@ $ git branch --no-merged [*进一步了解 Git `branch` 命令.*](http://git-scm.com/docs/git-branch) -### 用来浏览本地仓库的web服务器 +### Web Server for Browsing Local Repositories 使用Git的 `instaweb` 可以立即在 `gitweb`中浏览你的工作仓库。这个命令是个简单的脚步,配置了`gitweb`和用来浏览本地仓库的Web服务器。*(译者注:默认需要lighttpd支持)* ```bash @@ -656,10 +656,10 @@ $ git instaweb [*进一步了解 Git `instaweb` 命令.*](http://git-scm.com/docs/git-instaweb) -### Git配置 +### Git Configurations 所有Git配置都保存在你的`.gitconfig` 文件中。 -#### 别名 [ Aliases ] +#### Aliases 别名用来帮助你定义自己的git命令。比如你可以定义 `git a` 来运行 `git add --all`。 要添加一个别名, 一种方法是打开 `~/.gitconfig` 文件并添加如下内容: @@ -705,7 +705,7 @@ $ git config --global alias.ac 'add -A . && commit' | `git branches` | `git branch -a` | `git config --global alias.branches 'branch -a'` | | `git remotes` | `git remote -v` | `git config --global alias.remotes 'remote -v'` | -#### 自动纠错 +#### Auto-Correct 如果键入 `git comit` 你会看到如下输出: ```bash @@ -731,7 +731,7 @@ $ git comit -m "Message" # in 0.1 seconds automatically... ``` -#### 颜色 +#### Color 要在你的Git命令输出里加上颜色的话,可以用如下命令: ```bash @@ -740,7 +740,7 @@ $ git config --global color.ui 1 [*进一步了解 Git `config` 命令.*](http://git-scm.com/docs/git-config) -### Git参考资源 +### Git Resources | Title | Link | | ----- | ---- | | Official Git Site | http://git-scm.com/ | @@ -755,7 +755,7 @@ $ git config --global color.ui 1 | Git for Computer Scientists | http://eagain.net/articles/git-for-computer-scientists/ | | Git Magic | http://www-cs-students.stanford.edu/~blynn/gitmagic/ | -#### Git书籍 +#### Git Books | Title | Link | | ----- | ---- | | Pragmatic Version Control Using Git | http://www.pragprog.com/titles/tsgit/pragmatic-version-control-using-git | From 89ab2494976cd979a3016754ff59da0c81d086ed Mon Sep 17 00:00:00 2001 From: waterfox0323 Date: Wed, 30 Apr 2014 10:28:11 +0800 Subject: [PATCH 4/4] fix a mismatched brace --- README.zh-cn.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.zh-cn.md b/README.zh-cn.md index 554caba..687f6bb 100644 --- a/README.zh-cn.md +++ b/README.zh-cn.md @@ -131,7 +131,7 @@ https://github.com/rails/rails/compare/master@{2014-10-04}...master ### Compare Branches across Forked Repositories -想要对派生仓库Forked Repository)之间的分支进行比较,可以像下面这样修改URL实现: +想要对派生仓库(Forked Repository)之间的分支进行比较,可以像下面这样修改URL实现: ``` https://github.com/user/repo/compare/{foreign-user}:{branch}...{own-branch} @@ -186,10 +186,10 @@ Location: https://github.com/... 在仓库主页上提供了快捷键方便快速导航。 - - 按 `t` 键会打开一个文件浏览器。 Pressing `t` will bring up a file explorer. - - 按 `w` 键会打开分支选择菜单。 Pressing `w` will bring up the branch selector. - - 按 `s` 键会激活顶端的命令栏 (Command Bar)。Pressing `s` will select the Command Bar. - - 按 `l` 键编辑Issue列表页的标签。 Pressing `l` will edit labels on existing Issues. + - 按 `t` 键会打开一个文件浏览器。 + - 按 `w` 键会打开分支选择菜单。 + - 按 `s` 键会激活顶端的命令栏 (Command Bar)。 + - 按 `l` 键编辑Issue列表页的标签。 - **查看文件内容时**(如:`https://github.com/tiimgreen/github-cheat-sheet/blob/master/README.md`),按 `y` 键将会冻结这个页面,这样就算代码被修改了也不会影响你当前看到的。 按`?`查看当前页面支持的快捷键列表: