1
0
mirror of https://github.com/k88hudson/git-flight-rules.git synced 2025-06-17 05:21:35 -03:00

2 Commits

Author SHA1 Message Date
a5d990376f Add the rest of the commands 2017-12-19 19:46:59 -05:00
60b1b583a9 Adding submodule section 2017-12-19 19:46:59 -05:00
11 changed files with 178 additions and 7712 deletions

2
.gitignore vendored
View File

@ -1,2 +0,0 @@
node_modules/
package-lock.json

View File

@ -1,11 +0,0 @@
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

View File

@ -26,21 +26,3 @@ 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

660
README.md

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
# Git飞行规则(Flight Rules) # Git飞行规则(Flight Rules)
🌍 🌍
*[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)* *[English](README.md) ∙ [Русский](README_ru.md) ∙ [简体中文](README_zh-cn.md)*
#### 前言 #### 前言
@ -10,7 +10,7 @@
#### 什么是"飞行规则"? #### 什么是"飞行规则"?
这是一篇给宇航员这里就是指使用Git的程序员们的指南用来指导问题出现后的应对之法 一个 [宇航员指南](http://www.jsc.nasa.gov/news/columbia/fr_generic.pdf) (现在, 程序员们都在使用GIT) 是关于出现问题过后应该怎么操作
> *飞行规则(Flight Rules)* 是记录在手册上的来之不易的一系列知识,记录了某个事情发生的原因,以及怎样一步一步的进行处理。本质上, 它们是特定场景的非常详细的标准处理流程。 [...] > *飞行规则(Flight Rules)* 是记录在手册上的来之不易的一系列知识,记录了某个事情发生的原因,以及怎样一步一步的进行处理。本质上, 它们是特定场景的非常详细的标准处理流程。 [...]
@ -67,12 +67,6 @@
- [交互式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)
@ -93,6 +87,7 @@
<!-- 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>
@ -116,12 +111,12 @@ $ git log -n1 -p
如果你的提交信息(commit message)写错了且这次提交(commit)还没有推(push), 你可以通过下面的方法来修改提交信息(commit message): 如果你的提交信息(commit message)写错了且这次提交(commit)还没有推(push), 你可以通过下面的方法来修改提交信息(commit message):
```sh ```sh
$ git commit --amend --only $ git commit --amend
``` ```
这会打开你的默认编辑器, 在这里你可以编辑信息. 另一方面, 你也可以用一条命令一次完成: 这会打开你的默认编辑器, 在这里你可以编辑信息. 另一方面, 你也可以用一条命令一次完成:
```sh ```sh
$ git commit --amend --only -m 'xxxxxxx' $ git commit --amend -m 'xxxxxxx'
``` ```
如果你已经推(push)了这次提交(commit), 你可以修改这次提交(commit)然后强推(force push), 但是不推荐这么做。 如果你已经推(push)了这次提交(commit), 你可以修改这次提交(commit)然后强推(force push), 但是不推荐这么做。
@ -137,6 +132,7 @@ $ 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)里移除一个文件
@ -246,28 +242,25 @@ $ 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>
### 我想把暂存的内容变成未暂存,把未暂存的内容暂存起来 ### 我想把暂存的内容变成未暂存,把未暂存的内容暂存起来
多数情况下你应该将所有的内容变为未暂存然后再选择你想要的内容进行commit 这个有点困难, 我能想到的最好的方法是先stash未暂存的内容 然后重置(reset)再pop第一步stashed的内容, 最后再add它们
但假定你就是想要这么做这里你可以创建一个临时的commit来保存你已暂存的内容然后暂存你的未暂存的内容并进行stash。然后reset最后一个commit将原本暂存的内容变为未暂存最后stash pop回来。
```sh ```sh
$ git commit -m "WIP" $ git stash -k
$ git add . $ git reset --hard
$ git stash $ git stash pop
$ git reset HEAD^ $ git add -A
$ 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时加indexgit会把两个一起销毁所以staged里就空了
## 未暂存(Unstaged)的内容 ## 未暂存(Unstaged)的内容
<a href="move-unstaged-edits-to-new-branch"></a> <a href="move-unstaged-edits-to-new-branch"></a>
@ -499,6 +492,7 @@ HEAD is now at a13b85e
这时候, 这里可能会产生冲突, 参见[交互式 rebasing 章](#interactive-rebase) [**冲突节**](#merge-conflict) 解决冲突. 这时候, 这里可能会产生冲突, 参见[交互式 rebasing 章](#interactive-rebase) [**冲突节**](#merge-conflict) 解决冲突.
再者, 我们为bug #14 创建一个新的分支, 也基于`master`分支 再者, 我们为bug #14 创建一个新的分支, 也基于`master`分支
```sh ```sh
@ -513,6 +507,7 @@ 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里被合并的分支。 如果你不准备继续在这个分支里工作, 删除这个分支的本地拷贝会更干净,使你不会陷入工作分支和一堆陈旧分支的混乱之中。
@ -855,82 +850,6 @@ 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)
@ -1066,6 +985,7 @@ $ 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)

View File

@ -1,14 +0,0 @@
{
"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"
}
}