mirror of
https://github.com/k88hudson/git-flight-rules.git
synced 2025-06-17 05:21:35 -03:00
Compare commits
104 Commits
feat/commo
...
YaaMe-mast
Author | SHA1 | Date | |
---|---|---|---|
40a542d31a | |||
f1a2195372 | |||
4252773598 | |||
260a140bda | |||
5c57fb5ea5 | |||
896006ff4d | |||
241437d1fe | |||
1cef8c2032 | |||
16f81ed7b0 | |||
79c67f674e | |||
ad141eeeb6 | |||
a545b0851d | |||
ff548e28d8 | |||
d3ac210fe4 | |||
b14710acdf | |||
d4cf0fb88a | |||
8e697833ae | |||
73547ca942 | |||
3d6c00dded | |||
8b09e3fb58 | |||
5cfcca513c | |||
b67b184d8a | |||
ee10f43326 | |||
0d109a7f9c | |||
1877d108b0 | |||
42b5519891 | |||
9d16c95ee1 | |||
c9cfb71843 | |||
4b5cad207a | |||
db69499594 | |||
7cb8c1a105 | |||
bbcb8f6704 | |||
8854c326b9 | |||
d6e98fd537 | |||
bd388a89c5 | |||
ca49abe067 | |||
8809567e7a | |||
9b54d14dff | |||
066cf428e1 | |||
a3ece44263 | |||
911089c406 | |||
ebfe5dae13 | |||
4b6e19a5ea | |||
f4037ec5c1 | |||
20e4b2c10d | |||
23e4b8d4f3 | |||
bd9af24828 | |||
bbbead4bcd | |||
065ce6e742 | |||
9d11cb4e9b | |||
2e8a756862 | |||
4e96f71c28 | |||
ba88c82f94 | |||
9e15db0d59 | |||
57c4e3bc59 | |||
913e8285aa | |||
9102de6186 | |||
efb35a9607 | |||
c767e4b22a | |||
f8257b615b | |||
8f4ec811b3 | |||
3339385cdb | |||
02d9745c00 | |||
965b320695 | |||
661024bc32 | |||
1eb620d54c | |||
0b7921c8d5 | |||
9bc656bdcc | |||
d988a3ab10 | |||
83261c5b7a | |||
c2ffba97eb | |||
8cfa8e476a | |||
df439158b4 | |||
29a9c7cbca | |||
a06bef415e | |||
42472aaa94 | |||
0f16ad1e2d | |||
4f3582494d | |||
4d42bb9070 | |||
d8c55ae8c5 | |||
14ea0820c8 | |||
ea40bf75ca | |||
fb27b20f1f | |||
e0513d81c2 | |||
be480c4c35 | |||
3f85b185de | |||
f9792e9c68 | |||
590f63c7e6 | |||
5de8869df2 | |||
4dcb631734 | |||
e4e6ee08b1 | |||
26138f0f10 | |||
68820c1dc3 | |||
84322067fe | |||
7dc4eedb17 | |||
697dbb404f | |||
423eaf0ede | |||
ae8459b6da | |||
3966d41462 | |||
ca04c4bfb4 | |||
58fab97420 | |||
c91d1081c4 | |||
e5039cc2b9 | |||
f462bad54d |
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
node_modules/
|
||||||
|
package-lock.json
|
11
.travis.yml
Normal file
11
.travis.yml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
language: ruby
|
||||||
|
rvm:
|
||||||
|
- 2.2
|
||||||
|
before_script:
|
||||||
|
- gem install awesome_bot
|
||||||
|
- npm install
|
||||||
|
script:
|
||||||
|
- awesome_bot README.md --allow-dupe --allow-redirect --allow-ssl
|
||||||
|
- awesome_bot README_*.md --allow-dupe --allow-redirect --allow-ssl
|
||||||
|
- npm run toc
|
||||||
|
- npm run diff
|
@ -26,3 +26,21 @@ This is a community built document. Dive in and help out!
|
|||||||
```sh
|
```sh
|
||||||
(relevant branch)$ git blah blah
|
(relevant branch)$ git blah blah
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Translation
|
||||||
|
|
||||||
|
We use a translation tool called [GitLocalize][gl]. Please follow these steps to get started with your contributions:
|
||||||
|
|
||||||
|
1. Go to [GitLocalize's k88hudson/git-flight-rules repository][gl-repo].
|
||||||
|
1. Sign up using your GitHub account :octocat:.
|
||||||
|
1. Find the document you are going to translate.
|
||||||
|
1. Happy translating :sparkles: .
|
||||||
|
1. When you are done, send the translation for reviews.
|
||||||
|
1. The reviewed translation will be sent as a Pull Request to GitHub by the language moderator in the community.
|
||||||
|
|
||||||
|
To learn more about how GitLocalize works, visit their [help page][gl-help]. If you find any issues or feature requests, please file them in [GitLocalize's issue tracker][gl-issue-tracker].
|
||||||
|
|
||||||
|
[gl]: https://gitlocalize.com
|
||||||
|
[gl-help]: https://docs.gitlocalize.com/
|
||||||
|
[gl-issue-tracker]: https://github.com/gitlocalize/feedback
|
||||||
|
[gl-repo]: https://gitlocalize.com/repo/598
|
||||||
|
1453
README_es.md
Normal file
1453
README_es.md
Normal file
File diff suppressed because it is too large
Load Diff
1642
README_fr.md
Normal file
1642
README_fr.md
Normal file
File diff suppressed because it is too large
Load Diff
1588
README_kr.md
Normal file
1588
README_kr.md
Normal file
File diff suppressed because it is too large
Load Diff
741
README_ru.md
741
README_ru.md
File diff suppressed because it is too large
Load Diff
1645
README_vi.md
Normal file
1645
README_vi.md
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,7 @@
|
|||||||
# Git飞行规则(Flight Rules)
|
# Git飞行规则(Flight Rules)
|
||||||
|
|
||||||
🌍
|
🌍
|
||||||
*[English](README.md) ∙ [Русский](README_ru.md) ∙ [简体中文](README_zh-cn.md)*
|
*[English](README.md) ∙ [Español](README_es.md) ∙ [Русский](README_ru.md) ∙ [简体中文](README_zh-CN.md)∙ [한국어](README_kr.md) ∙ [Tiếng Việt](README_vi.md) ∙ [Français](README_fr.md)*
|
||||||
|
|
||||||
#### 前言
|
#### 前言
|
||||||
|
|
||||||
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
#### 什么是"飞行规则"?
|
#### 什么是"飞行规则"?
|
||||||
|
|
||||||
一个 [宇航员指南](http://www.jsc.nasa.gov/news/columbia/fr_generic.pdf) (现在, 程序员们都在使用GIT) 是关于出现问题过后应该怎么操作。
|
这是一篇给宇航员(这里就是指使用Git的程序员们)的指南,用来指导问题出现后的应对之法。
|
||||||
|
|
||||||
> *飞行规则(Flight Rules)* 是记录在手册上的来之不易的一系列知识,记录了某个事情发生的原因,以及怎样一步一步的进行处理。本质上, 它们是特定场景的非常详细的标准处理流程。 [...]
|
> *飞行规则(Flight Rules)* 是记录在手册上的来之不易的一系列知识,记录了某个事情发生的原因,以及怎样一步一步的进行处理。本质上, 它们是特定场景的非常详细的标准处理流程。 [...]
|
||||||
|
|
||||||
@ -67,6 +67,12 @@
|
|||||||
- [交互式rebase(interactive rebase)可能出现的问题](#%E4%BA%A4%E4%BA%92%E5%BC%8Frebaseinteractive-rebase%E5%8F%AF%E8%83%BD%E5%87%BA%E7%8E%B0%E7%9A%84%E9%97%AE%E9%A2%98)
|
- [交互式rebase(interactive rebase)可能出现的问题](#%E4%BA%A4%E4%BA%92%E5%BC%8Frebaseinteractive-rebase%E5%8F%AF%E8%83%BD%E5%87%BA%E7%8E%B0%E7%9A%84%E9%97%AE%E9%A2%98)
|
||||||
- [这个rebase 编辑屏幕出现'noop'](#%E8%BF%99%E4%B8%AArebase-%E7%BC%96%E8%BE%91%E5%B1%8F%E5%B9%95%E5%87%BA%E7%8E%B0noop)
|
- [这个rebase 编辑屏幕出现'noop'](#%E8%BF%99%E4%B8%AArebase-%E7%BC%96%E8%BE%91%E5%B1%8F%E5%B9%95%E5%87%BA%E7%8E%B0noop)
|
||||||
- [有冲突的情况](#%E6%9C%89%E5%86%B2%E7%AA%81%E7%9A%84%E6%83%85%E5%86%B5)
|
- [有冲突的情况](#%E6%9C%89%E5%86%B2%E7%AA%81%E7%9A%84%E6%83%85%E5%86%B5)
|
||||||
|
- [Stash](#stash)
|
||||||
|
- [暂存所有改动](#%E6%9A%82%E5%AD%98%E6%89%80%E6%9C%89%E6%94%B9%E5%8A%A8)
|
||||||
|
- [暂存指定文件](#%E6%9A%82%E5%AD%98%E6%8C%87%E5%AE%9A%E6%96%87%E4%BB%B6)
|
||||||
|
- [暂存时记录消息](#%E6%9A%82%E5%AD%98%E6%97%B6%E8%AE%B0%E5%BD%95%E6%B6%88%E6%81%AF)
|
||||||
|
- [使用某个指定暂存](#%E4%BD%BF%E7%94%A8%E6%9F%90%E4%B8%AA%E6%8C%87%E5%AE%9A%E6%9A%82%E5%AD%98)
|
||||||
|
- [暂存时保留未暂存的内容](#%E6%9A%82%E5%AD%98%E6%97%B6%E4%BF%9D%E7%95%99%E6%9C%AA%E6%9A%82%E5%AD%98%E7%9A%84%E5%86%85%E5%AE%B9)
|
||||||
- [杂项(Miscellaneous Objects)](#%E6%9D%82%E9%A1%B9miscellaneous-objects)
|
- [杂项(Miscellaneous Objects)](#%E6%9D%82%E9%A1%B9miscellaneous-objects)
|
||||||
- [克隆所有子模块](#%E5%85%8B%E9%9A%86%E6%89%80%E6%9C%89%E5%AD%90%E6%A8%A1%E5%9D%97)
|
- [克隆所有子模块](#%E5%85%8B%E9%9A%86%E6%89%80%E6%9C%89%E5%AD%90%E6%A8%A1%E5%9D%97)
|
||||||
- [删除标签(tag)](#%E5%88%A0%E9%99%A4%E6%A0%87%E7%AD%BEtag)
|
- [删除标签(tag)](#%E5%88%A0%E9%99%A4%E6%A0%87%E7%AD%BEtag)
|
||||||
@ -87,7 +93,6 @@
|
|||||||
|
|
||||||
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
||||||
|
|
||||||
|
|
||||||
## 编辑提交(editting commits)
|
## 编辑提交(editting commits)
|
||||||
|
|
||||||
<a name="diff-last"></a>
|
<a name="diff-last"></a>
|
||||||
@ -111,12 +116,12 @@ $ git log -n1 -p
|
|||||||
如果你的提交信息(commit message)写错了且这次提交(commit)还没有推(push), 你可以通过下面的方法来修改提交信息(commit message):
|
如果你的提交信息(commit message)写错了且这次提交(commit)还没有推(push), 你可以通过下面的方法来修改提交信息(commit message):
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ git commit --amend
|
$ git commit --amend --only
|
||||||
```
|
```
|
||||||
这会打开你的默认编辑器, 在这里你可以编辑信息. 另一方面, 你也可以用一条命令一次完成:
|
这会打开你的默认编辑器, 在这里你可以编辑信息. 另一方面, 你也可以用一条命令一次完成:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ git commit --amend -m 'xxxxxxx'
|
$ git commit --amend --only -m 'xxxxxxx'
|
||||||
```
|
```
|
||||||
|
|
||||||
如果你已经推(push)了这次提交(commit), 你可以修改这次提交(commit)然后强推(force push), 但是不推荐这么做。
|
如果你已经推(push)了这次提交(commit), 你可以修改这次提交(commit)然后强推(force push), 但是不推荐这么做。
|
||||||
@ -132,7 +137,6 @@ $ git commit --amend --author "New Authorname <authoremail@mydomain.com>"
|
|||||||
|
|
||||||
如果你需要修改所有历史, 参考 'git filter-branch'的指南页.
|
如果你需要修改所有历史, 参考 'git filter-branch'的指南页.
|
||||||
|
|
||||||
|
|
||||||
<a href="#i-want-to-remove-a-file-from-a-commit"></a>
|
<a href="#i-want-to-remove-a-file-from-a-commit"></a>
|
||||||
### 我想从一个提交(commit)里移除一个文件
|
### 我想从一个提交(commit)里移除一个文件
|
||||||
|
|
||||||
@ -242,25 +246,28 @@ $ git add -N filename.x
|
|||||||
|
|
||||||
然后, 你需要用 `e` 选项来手动选择需要添加的行,执行 `git diff --cached` 将会显示哪些行暂存了哪些行只是保存在本地了。
|
然后, 你需要用 `e` 选项来手动选择需要添加的行,执行 `git diff --cached` 将会显示哪些行暂存了哪些行只是保存在本地了。
|
||||||
|
|
||||||
|
|
||||||
<a href="stage-in-two-commits"></a>
|
<a href="stage-in-two-commits"></a>
|
||||||
### 我想把在一个文件里的变化(changes)加到两个提交(commit)里
|
### 我想把在一个文件里的变化(changes)加到两个提交(commit)里
|
||||||
|
|
||||||
`git add` 会把整个文件加入到一个提交. `git add -p` 允许交互式的选择你想要提交的部分.
|
`git add` 会把整个文件加入到一个提交. `git add -p` 允许交互式的选择你想要提交的部分.
|
||||||
|
|
||||||
|
|
||||||
<a href="unstaging-edits-and-staging-the-unstaged"></a>
|
<a href="unstaging-edits-and-staging-the-unstaged"></a>
|
||||||
### 我想把暂存的内容变成未暂存,把未暂存的内容暂存起来
|
### 我想把暂存的内容变成未暂存,把未暂存的内容暂存起来
|
||||||
|
|
||||||
这个有点困难, 我能想到的最好的方法是先stash未暂存的内容, 然后重置(reset),再pop第一步stashed的内容, 最后再add它们。
|
多数情况下,你应该将所有的内容变为未暂存,然后再选择你想要的内容进行commit。
|
||||||
|
但假定你就是想要这么做,这里你可以创建一个临时的commit来保存你已暂存的内容,然后暂存你的未暂存的内容并进行stash。然后reset最后一个commit将原本暂存的内容变为未暂存,最后stash pop回来。
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ git stash -k
|
$ git commit -m "WIP"
|
||||||
$ git reset --hard
|
$ git add .
|
||||||
$ git stash pop
|
$ git stash
|
||||||
$ git add -A
|
$ git reset HEAD^
|
||||||
|
$ git stash pop --index 0
|
||||||
```
|
```
|
||||||
|
|
||||||
|
注意1: 这里使用`pop`仅仅是因为想尽可能保持幂等。
|
||||||
|
注意2: 假如你不加上`--index`你会把暂存的文件标记为为存储.这个[链接](https://stackoverflow.com/questions/31595873/git-stash-with-staged-files-does-stash-convert-staged-files-to-unstaged?answertab=active#tab-top) 解释得比较清楚。(不过是英文的,其大意是说,这是一个较为底层的问题,stash时会做2个commit,其中一个会记录index状态,staged的文件等东西,另一个记录worktree和其他的一些东西,如果你不在apply时加index,git会把两个一起销毁,所以staged里就空了)。
|
||||||
|
|
||||||
## 未暂存(Unstaged)的内容
|
## 未暂存(Unstaged)的内容
|
||||||
|
|
||||||
<a href="move-unstaged-edits-to-new-branch"></a>
|
<a href="move-unstaged-edits-to-new-branch"></a>
|
||||||
@ -492,7 +499,6 @@ HEAD is now at a13b85e
|
|||||||
|
|
||||||
这时候, 这里可能会产生冲突, 参见[交互式 rebasing 章](#interactive-rebase) [**冲突节**](#merge-conflict) 解决冲突.
|
这时候, 这里可能会产生冲突, 参见[交互式 rebasing 章](#interactive-rebase) [**冲突节**](#merge-conflict) 解决冲突.
|
||||||
|
|
||||||
|
|
||||||
再者, 我们为bug #14 创建一个新的分支, 也基于`master`分支
|
再者, 我们为bug #14 创建一个新的分支, 也基于`master`分支
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
@ -507,7 +513,6 @@ HEAD is now at a13b85e
|
|||||||
(14)$ git cherry-pick 5ea5173
|
(14)$ git cherry-pick 5ea5173
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
<a name="delete-stale-local-branches"></a>
|
<a name="delete-stale-local-branches"></a>
|
||||||
### 我想删除上游(upstream)分支被删除了的本地分支
|
### 我想删除上游(upstream)分支被删除了的本地分支
|
||||||
一旦你在github 上面合并(merge)了一个pull request, 你就可以删除你fork里被合并的分支。 如果你不准备继续在这个分支里工作, 删除这个分支的本地拷贝会更干净,使你不会陷入工作分支和一堆陈旧分支的混乱之中。
|
一旦你在github 上面合并(merge)了一个pull request, 你就可以删除你fork里被合并的分支。 如果你不准备继续在这个分支里工作, 删除这个分支的本地拷贝会更干净,使你不会陷入工作分支和一堆陈旧分支的混乱之中。
|
||||||
@ -850,6 +855,82 @@ Changes not staged for commit:
|
|||||||
(my-branch)$ git rebase --abort
|
(my-branch)$ git rebase --abort
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<a name="stashing"></a>
|
||||||
|
## Stash
|
||||||
|
|
||||||
|
### 暂存所有改动
|
||||||
|
|
||||||
|
暂存你工作目录下的所有改动
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ git stash
|
||||||
|
```
|
||||||
|
|
||||||
|
你可以使用`-u`来排除一些文件
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ git stash -u
|
||||||
|
```
|
||||||
|
|
||||||
|
### 暂存指定文件
|
||||||
|
|
||||||
|
假设你只想暂存某一个文件
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ git stash push working-directory-path/filename.ext
|
||||||
|
```
|
||||||
|
|
||||||
|
假设你想暂存多个文件
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ git stash push working-directory-path/filename1.ext working-directory-path/filename2.ext
|
||||||
|
```
|
||||||
|
|
||||||
|
<a name="stash-msg"></a>
|
||||||
|
### 暂存时记录消息
|
||||||
|
|
||||||
|
这样你可以在`list`时看到它
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ git stash save <message>
|
||||||
|
```
|
||||||
|
或
|
||||||
|
```sh
|
||||||
|
$ git stash push -m <message>
|
||||||
|
```
|
||||||
|
<a name="stash-apply-specific"></a>
|
||||||
|
### 使用某个指定暂存
|
||||||
|
|
||||||
|
首先你可以查看你的`stash`记录
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ git stash list
|
||||||
|
```
|
||||||
|
|
||||||
|
然后你可以`apply`某个`stash`
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ git stash apply "stash@{n}"
|
||||||
|
```
|
||||||
|
|
||||||
|
此处, 'n'是`stash`在栈中的位置,最上层的`stash`会是0
|
||||||
|
|
||||||
|
除此之外,也可以使用时间标记(假如你能记得的话)。
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ git stash apply "stash@{2.hours.ago}"
|
||||||
|
```
|
||||||
|
|
||||||
|
<a href="stage-and-keep-unstaged"></a>
|
||||||
|
### 暂存时保留未暂存的内容
|
||||||
|
|
||||||
|
你需要手动create一个`stash commit`, 然后使用`git stash store`。
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ git stash create
|
||||||
|
$ git stash store -m "commit-message" CREATED_SHA1
|
||||||
|
```
|
||||||
|
|
||||||
<a name="miscellaneous-objects"></a>
|
<a name="miscellaneous-objects"></a>
|
||||||
## 杂项(Miscellaneous Objects)
|
## 杂项(Miscellaneous Objects)
|
||||||
|
|
||||||
@ -985,7 +1066,6 @@ $ git reset --hard 0254ea7
|
|||||||
|
|
||||||
([摘自](https://www.atlassian.com/git/tutorials/rewriting-history/git-reflog)).
|
([摘自](https://www.atlassian.com/git/tutorials/rewriting-history/git-reflog)).
|
||||||
|
|
||||||
|
|
||||||
# 其它资源(Other Resources)
|
# 其它资源(Other Resources)
|
||||||
|
|
||||||
## 书(Books)
|
## 书(Books)
|
14
package.json
Normal file
14
package.json
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"private": true,
|
||||||
|
"name": "git-flight-rules",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "Flight rules for git",
|
||||||
|
"scripts": {
|
||||||
|
"toc": "doctoc --github README.md README_*.md",
|
||||||
|
"diff": "test -z \"`git diff -- README.md`\" && test -z \"`git diff -- README_*.md`\""
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"doctoc": "^1.3.0",
|
||||||
|
"anchor-markdown-header": "thlorenz/anchor-markdown-header#master"
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user