mirror of
https://github.com/k88hudson/git-flight-rules.git
synced 2025-06-16 04:44:07 -03:00
Compare commits
4 Commits
4b209049d9
...
21ff580f4d
Author | SHA1 | Date | |
---|---|---|---|
21ff580f4d | |||
589f1e474e | |||
bee4819794 | |||
7c4841b91e |
153
README_zh-TW.md
153
README_zh-TW.md
@ -103,11 +103,23 @@
|
||||
- [貯存時附加訊息](#%E8%B2%AF%E5%AD%98%E6%99%82%E9%99%84%E5%8A%A0%E8%A8%8A%E6%81%AF)
|
||||
- [套用指定貯存](#%E5%A5%97%E7%94%A8%E6%8C%87%E5%AE%9A%E8%B2%AF%E5%AD%98)
|
||||
- [貯存時保留未暫存的內容](#%E8%B2%AF%E5%AD%98%E6%99%82%E4%BF%9D%E7%95%99%E6%9C%AA%E6%9A%AB%E5%AD%98%E7%9A%84%E5%85%A7%E5%AE%B9)
|
||||
- [雜項](#%E9%9B%9C%E9%A0%85)
|
||||
- [尋找](#%E5%B0%8B%E6%89%BE)
|
||||
- [我想找到引入特定字串的提交](#%E6%88%91%E6%83%B3%E6%89%BE%E5%88%B0%E5%BC%95%E5%85%A5%E7%89%B9%E5%AE%9A%E5%AD%97%E4%B8%B2%E7%9A%84%E6%8F%90%E4%BA%A4)
|
||||
- [我想找到特定作者/提交者的提交](#%E6%88%91%E6%83%B3%E6%89%BE%E5%88%B0%E7%89%B9%E5%AE%9A%E4%BD%9C%E8%80%85%EF%BC%8F%E6%8F%90%E4%BA%A4%E8%80%85%E7%9A%84%E6%8F%90%E4%BA%A4)
|
||||
- [我想找到包含特定檔案的提交](#%E6%88%91%E6%83%B3%E6%89%BE%E5%88%B0%E5%8C%85%E5%90%AB%E7%89%B9%E5%AE%9A%E6%AA%94%E6%A1%88%E7%9A%84%E6%8F%90%E4%BA%A4)
|
||||
- [我想找到特定函式的歷史記錄](#%E6%88%91%E6%83%B3%E6%89%BE%E5%88%B0%E7%89%B9%E5%AE%9A%E5%87%BD%E5%BC%8F%E7%9A%84%E6%AD%B7%E5%8F%B2%E8%A8%98%E9%8C%84)
|
||||
- [我想找到引用特定提交的標籤](#%E6%88%91%E6%83%B3%E6%89%BE%E5%88%B0%E5%BC%95%E7%94%A8%E7%89%B9%E5%AE%9A%E6%8F%90%E4%BA%A4%E7%9A%84%E6%A8%99%E7%B1%A4)
|
||||
- [子模組](#%E5%AD%90%E6%A8%A1%E7%B5%84)
|
||||
- [複製所有子模組](#%E8%A4%87%E8%A3%BD%E6%89%80%E6%9C%89%E5%AD%90%E6%A8%A1%E7%B5%84)
|
||||
- [移除子模組](#%E7%A7%BB%E9%99%A4%E5%AD%90%E6%A8%A1%E7%B5%84)
|
||||
- [雜項](#%E9%9B%9C%E9%A0%85)
|
||||
- [從另一個分支拷貝檔案](#%E5%BE%9E%E5%8F%A6%E4%B8%80%E5%80%8B%E5%88%86%E6%94%AF%E6%8B%B7%E8%B2%9D%E6%AA%94%E6%A1%88)
|
||||
- [恢復刪除的檔案](#%E6%81%A2%E5%BE%A9%E5%88%AA%E9%99%A4%E7%9A%84%E6%AA%94%E6%A1%88)
|
||||
- [刪除標籤](#%E5%88%AA%E9%99%A4%E6%A8%99%E7%B1%A4)
|
||||
- [恢復已刪除標籤](#%E6%81%A2%E5%BE%A9%E5%B7%B2%E5%88%AA%E9%99%A4%E6%A8%99%E7%B1%A4)
|
||||
- [已刪除修補檔](#%E5%B7%B2%E5%88%AA%E9%99%A4%E4%BF%AE%E8%A3%9C%E6%AA%94)
|
||||
- [將版本庫導出為 Zip 檔](#%E5%B0%87%E7%89%88%E6%9C%AC%E5%BA%AB%E5%B0%8E%E5%87%BA%E7%82%BA-zip-%E6%AA%94)
|
||||
- [推送有相同名稱的分支與標籤](#%E6%8E%A8%E9%80%81%E6%9C%89%E7%9B%B8%E5%90%8C%E5%90%8D%E7%A8%B1%E7%9A%84%E5%88%86%E6%94%AF%E8%88%87%E6%A8%99%E7%B1%A4)
|
||||
- [追蹤檔案](#%E8%BF%BD%E8%B9%A4%E6%AA%94%E6%A1%88)
|
||||
- [我只想改變一個檔案名字的大小寫,而不修改內容](#%E6%88%91%E5%8F%AA%E6%83%B3%E6%94%B9%E8%AE%8A%E4%B8%80%E5%80%8B%E6%AA%94%E6%A1%88%E5%90%8D%E5%AD%97%E7%9A%84%E5%A4%A7%E5%B0%8F%E5%AF%AB%E8%80%8C%E4%B8%8D%E4%BF%AE%E6%94%B9%E5%85%A7%E5%AE%B9)
|
||||
- [我想從 Git 刪除一個檔案,但保留該檔案](#%E6%88%91%E6%83%B3%E5%BE%9E-git-%E5%88%AA%E9%99%A4%E4%B8%80%E5%80%8B%E6%AA%94%E6%A1%88%E4%BD%86%E4%BF%9D%E7%95%99%E8%A9%B2%E6%AA%94%E6%A1%88)
|
||||
@ -1401,7 +1413,7 @@ $ git checkout --ours README.md
|
||||
$ git stash
|
||||
```
|
||||
|
||||
可以使用 `-u` 選項排除一些檔案:
|
||||
也貯存未追蹤的檔案:
|
||||
|
||||
```sh
|
||||
$ git stash -u
|
||||
@ -1437,7 +1449,7 @@ $ git stash push -m <message>
|
||||
|
||||
### 套用指定貯存
|
||||
|
||||
可以先列出擁有的貯存:
|
||||
先列出貯存:
|
||||
|
||||
```sh
|
||||
$ git stash list
|
||||
@ -1464,7 +1476,63 @@ $ git stash create
|
||||
$ git stash store -m "commit-message" CREATED_SHA1
|
||||
```
|
||||
|
||||
## 雜項
|
||||
## 尋找
|
||||
|
||||
### 我想找到引入特定字串的提交
|
||||
|
||||
```sh
|
||||
$ git log -S [要尋找的字串]
|
||||
```
|
||||
|
||||
常見的選項:
|
||||
* `--source` 顯示引用名稱。
|
||||
* `--all` 尋找每個分支。
|
||||
* `--reverse` 以相反順序印出,即第一個為最早如此變更的提交。
|
||||
|
||||
### 我想找到特定作者/提交者的提交
|
||||
|
||||
尋找特定作者/提交者的提交:
|
||||
|
||||
```sh
|
||||
$ git log --author=[名字或 email]
|
||||
$ git log --committer=[名字或 email]
|
||||
```
|
||||
|
||||
注意作者與提交者並不相同,`--author` 是寫下程式碼的人,`--committer` 則是提交程式碼的人。
|
||||
|
||||
### 我想找到包含特定檔案的提交
|
||||
|
||||
```sh
|
||||
$ git log -- [檔案路徑]
|
||||
```
|
||||
|
||||
也可以在檔案路徑中使用萬用字元,如:
|
||||
|
||||
```sh
|
||||
$ git log -- **/*.js
|
||||
```
|
||||
|
||||
使用萬用字元時,以 `--name-status` 列出提交的檔案會有幫助:
|
||||
|
||||
```sh
|
||||
$ git log --name-status -- **/*.js
|
||||
```
|
||||
|
||||
### 我想找到特定函式的歷史記錄
|
||||
|
||||
```sh
|
||||
$ git log -L :[函式名稱]:[檔案路徑]
|
||||
```
|
||||
|
||||
也可以結合其他 `git log` 選項使用,例如[修訂版範圍](https://git-scm.com/docs/gitrevisions)和[提交限制](https://git-scm.com/docs/git-log/#_commit_limiting)。
|
||||
|
||||
### 我想找到引用特定提交的標籤
|
||||
|
||||
```sh
|
||||
$ git tag --contains [提交]
|
||||
```
|
||||
|
||||
## 子模組
|
||||
|
||||
### 複製所有子模組
|
||||
|
||||
@ -1478,11 +1546,44 @@ $ git clone --recursive git://github.com/foo/bar.git
|
||||
$ git submodule update --init --recursive
|
||||
```
|
||||
|
||||
### 移除子模組
|
||||
|
||||
創建子模組很直覺,但刪除不是,你需要:
|
||||
|
||||
```sh
|
||||
$ git submodule deinit [子模組名稱]
|
||||
$ git rm [子模組名稱]
|
||||
$ git rm --cached [子模組名稱]
|
||||
$ rm -rf .git/modules/[子模組名稱]
|
||||
```
|
||||
|
||||
## 雜項
|
||||
|
||||
### 從另一個分支拷貝檔案
|
||||
|
||||
```sh
|
||||
$ git checkout [分支] -- [檔案名稱]
|
||||
```
|
||||
|
||||
### 恢復刪除的檔案
|
||||
|
||||
先找到該檔案最後存在的提交:
|
||||
|
||||
```sh
|
||||
$ git rev-list -n 1 HEAD -- [檔案名稱]
|
||||
```
|
||||
|
||||
然後簽出該檔案:
|
||||
|
||||
```sh
|
||||
$ git checkout [刪除檔案的提交]^ -- [檔案名稱]
|
||||
```
|
||||
|
||||
### 刪除標籤
|
||||
|
||||
```sh
|
||||
$ git tag -d <tag_name>
|
||||
$ git push <remote> :refs/tags/<tag_name>
|
||||
$ git tag -d [標籤名稱]
|
||||
$ git push [遠端] :refs/tags/[標籤名稱]
|
||||
```
|
||||
|
||||
### 恢復已刪除標籤
|
||||
@ -1493,17 +1594,49 @@ $ git push <remote> :refs/tags/<tag_name>
|
||||
$ git fsck --unreachable | grep tag
|
||||
```
|
||||
|
||||
記下這個標籤的雜湊值,然後用 Git 的 [`update-ref`](http://git-scm.com/docs/git-update-ref):
|
||||
記下這個標籤的雜湊值,然後用 [`git update-ref`](http://git-scm.com/docs/git-update-ref):
|
||||
|
||||
```sh
|
||||
$ git update-ref refs/tags/<tag_name> <hash>
|
||||
$ git update-ref refs/tags/[標籤名稱] [雜湊值]
|
||||
```
|
||||
|
||||
### 已刪除修補檔
|
||||
|
||||
如果有人在 GitHub 上向你提出了拉取請求,但他接著刪除了他的分叉,你無法複製他的提交或使用 `git am`。在這種情況下,最好手動的查看他們的提交,把它們拷貝到一個新的本機分支,然後提交。
|
||||
如果有人在 GitHub 上向你提出了拉取請求,但他接著刪除了他的分叉,因為 [`.diff` 和 `.patch` URL](https://github.com/blog/967-github-secrets) 失效,你無法複製他的提交或使用 `git am`。但你可以透過 [GitHub 的特殊引用](https://gist.github.com/piscisaureus/3342247)簽出拉取請求本身。例如將拉取請求 #1 的內容抓取到名為 `pr_1` 的新分支:
|
||||
|
||||
最後,再修改作者,參見[〈變更作者〉](#commit-wrong-author)。然後,套用更動,再發起一個新的拉取請求。
|
||||
```sh
|
||||
$ git fetch [遠端] refs/pull/1/head:pr_1
|
||||
From github.com:foo/bar
|
||||
* [new ref] refs/pull/1/head -> pr_1
|
||||
```
|
||||
|
||||
### 將版本庫導出為 Zip 檔
|
||||
|
||||
```sh
|
||||
$ git archive --format zip --output [zip 的完整檔案路徑] main
|
||||
```
|
||||
|
||||
### 推送有相同名稱的分支與標籤
|
||||
|
||||
如果遠端有與分支同名的標籤,若試圖以標準的 `git push [遠端] [分支]` 命令推送該分支時會得到以下錯誤:
|
||||
|
||||
```sh
|
||||
$ git push [遠端] [分支]
|
||||
error: dst refspec same matches more than one.
|
||||
error: failed to push some refs to '<git server>'
|
||||
```
|
||||
|
||||
指明要推送 `HEAD` 引用來修正這個問題:
|
||||
|
||||
```sh
|
||||
$ git push [遠端] refs/heads/[分支名稱]
|
||||
```
|
||||
|
||||
相對地,推送標籤使用:
|
||||
|
||||
```sh
|
||||
$ git push [遠端] refs/tags/[標籤名稱]
|
||||
```
|
||||
|
||||
## 追蹤檔案
|
||||
|
||||
|
Reference in New Issue
Block a user