1
0
mirror of https://github.com/k88hudson/git-flight-rules.git synced 2025-06-16 12:54:01 -03:00

183 Commits

Author SHA1 Message Date
69f7635ed1 Update README.md : Fix typo (#370) 2025-04-12 10:26:43 +12:00
405a57c6d4 chore: Update Vietnamese translation (#363) 2024-08-27 14:17:08 +12:00
f4dabebc83 Merge pull request #362 from lumynou5/change-author
Add method to change authors for multiple commits
2024-05-27 20:53:00 -03:00
449e36d21b Add information about filter-branch back 2024-05-21 11:05:33 +08:00
819b14a73f Add method to change authors for multiple commits 2024-05-14 13:58:41 +08:00
b752196266 Fix link in README_ja.md (#361) 2024-03-18 10:17:15 -04:00
1037756725 Adding Git cartoons by Allison Horst. (#360)
Adding https://allisonhorst.com/git-github. 

Also, alphabetized section.
2024-02-23 10:08:06 +11:00
e1fd8abce8 Improve (remove) "Unstaged Edits" (#358) 2023-09-27 10:35:07 -04:00
02cee38025 Fixed typos for internal and external links (#357)
* Update anchor link to `push.default` documentation

* Update anchor link to `rebase --merge` documentation

* Fix link typos
2023-07-21 13:41:29 -04:00
c3df156871 Clarify the use of --amend (#354)
Co-authored-by: Richard Littauer <richard.littauer@gmail.com>
2023-06-28 11:56:19 +02:00
0b1f7bcdaf Improve zh-TW (#352) 2023-06-28 11:51:46 +02:00
aefc20702d fix: typo in README.md (#343) 2023-02-01 02:18:00 +00:00
8413701f30 Update info how to reset local branch to remote-tracking branch (#344) 2023-02-01 02:17:42 +00:00
3ff35c8642 Update reflog shortname with an ancestry reference (#345) 2023-02-01 02:17:10 +00:00
18c656604b Edits: changes in specific file between commits/branches (#346) 2023-02-01 02:16:27 +00:00
c34b49ff5a Correct punctuations and improve readability for zh-TW (#347) 2023-02-01 02:16:12 +00:00
3d101f5456 added I want to move a change from one commit to another (#342)
Co-authored-by: Eric Feunekes <eric.feunekes@pwc.com>
2022-12-06 23:59:15 +00:00
a8897df82d Add traditional Chinese with terminology changes (#341) 2022-12-06 23:58:46 +00:00
04507b8fc3 fix: README_zh-CN (#339) 2022-11-28 21:53:27 +00:00
5f1db99e49 Fix "gim" typo (#331) 2021-09-22 16:37:55 -04:00
65bd59262f Title of Chris Hadfield's book is incorrect (#319)
It is actually "An Astronaut's Guide to Life on Earth"

https://www.worldcat.org/title/astronauts-guide-to-life-on-earth/oclc/872711307
2021-07-04 13:13:22 -04:00
7caa59575b Update Vietnamese translations (#318) 2021-06-25 12:29:37 -04:00
eb36083cbd Fix Spelling Vietnamese (#315) 2021-05-17 10:10:52 -04:00
5816815453 New rule: split a branch into two (#314) 2021-03-18 08:42:18 -04:00
9e1faad0e9 chore: Update ToC 2021-02-25 09:16:54 -05:00
ef15b6cd8b Removed hint configure color.ui auto: (#311)
color.ui defaults to "auto" since git version 1.8.4 from August 2013
(https://github.com/git/git/releases/tag/v1.8.4) so it is probably not
needed to set this option anymore.
2021-01-26 12:47:47 -05:00
fa148da698 Replace master with main (issue/#308) (#309) 2020-12-01 09:44:45 -05:00
82f0b3994d add patch workflow to sharing code section (#307) 2020-11-28 16:15:14 -05:00
cfca81c274 Adding 日本語 to all of the lists 2020-04-30 17:01:35 -04:00
3a855c6e37 Run doctoc 2020-02-27 23:15:42 +09:00
SI
6b0d0090f5 Elaborate Introduction 2020-02-27 23:06:44 +09:00
421e7e9c75 Unify spacing 2020-02-27 22:59:27 +09:00
178b145f41 Avoid colon in sentences 2020-02-27 22:57:38 +09:00
ceb2109a3f Translate comment 2020-02-27 22:56:47 +09:00
e0c6fa128e Unify wording; 次のコマンド -> 次 2020-02-27 22:56:11 +09:00
c87aaf142f Unify wording; 編集内容 -> 編集 2020-02-27 22:54:27 +09:00
cc284a63a3 Unify wording; ステージング -> ステージ 2020-02-27 22:51:49 +09:00
a555e4295e Specify wording; 任意の -> 特定の/全ての 2020-02-27 22:49:30 +09:00
d927b41906 Unify wording; 既に -> すでに 2020-02-27 22:45:15 +09:00
4935207bd7 Unify wording; 編集内容 -> 編集 2020-02-27 22:43:50 +09:00
SI
25397ac3f2 Elaborate # Other Resources 2020-02-27 22:22:15 +09:00
SI
3868e6ccf6 Elaborate ## I've no idea what I did wrong 2020-02-27 22:18:16 +09:00
SI
ba331a523b Elaborate ## Configuration 2020-02-27 22:14:20 +09:00
SI
718e24db95 Elaborate ## Debugging with Git 2020-02-27 22:11:36 +09:00
SI
94b47ea011 Elaborate ## Tracking Files 2020-02-27 22:08:09 +09:00
SI
5f5a60b242 Elaborate ## Miscellaneous Objects 2020-02-27 22:05:23 +09:00
SI
f2734d6361 Elaborate ## Submodules 2020-02-27 22:02:48 +09:00
SI
37f9a744ef Elaborate ## Finding 2020-02-27 22:01:32 +09:00
SI
cd9bfd055a Elaborate ## Stash 2020-02-27 21:57:28 +09:00
SI
6fdf31d5b4 Elaborate ## Rebasing and Merging 2020-02-27 21:53:30 +09:00
SI
b3d43db200 Elaborate ## Branches 2020-02-24 19:36:17 +09:00
SI
b98b984070 Elaborate ## Unstaged Edits 2020-02-24 19:02:56 +09:00
SI
59307fd087 Elaborate ## Staging 2020-02-24 18:55:52 +09:00
SI
ec45354d85 Elaborate ## Editing Commits 2020-02-24 18:50:49 +09:00
SI
7d9dd08625 Elaborate ## Repositories 2020-02-24 18:12:18 +09:00
SI
964d02f7f6 Translate Introduction 2020-02-23 11:47:15 +09:00
SI
3aa4c6d9a6 Translate # Other Resources 2020-02-22 20:28:09 +09:00
SI
85c967e090 Translate ## Git Shortcuts 2020-02-22 19:53:18 +09:00
SI
f370468b5e Translate ## I've no idea what I did wrong 2020-02-22 19:41:53 +09:00
SI
3f3e2cde29 Translate ## Configuration 2020-02-22 18:48:48 +09:00
SI
40726c96f7 Translate ## Debugging with Git 2020-02-20 22:12:26 +09:00
SI
0e0971809f Translate ## Tracking Files 2020-02-20 21:55:36 +09:00
SI
e09b1cac83 Translate ## Miscellaneous Objects 2020-02-20 21:37:19 +09:00
SI
675c08afd9 Translate ## Submodules 2020-02-20 21:17:40 +09:00
SI
96c427d51d Translate ## Finding 2020-02-17 22:00:30 +09:00
SI
c20458cbff Translate ## Stash 2020-02-17 21:22:39 +09:00
SI
b01317d586 Translate ## Rebasing and Merging 2020-02-16 10:57:43 +09:00
SI
e6d3f8a659 Translate ## Branches 2020-02-15 11:02:54 +09:00
SI
1d52880553 Translate ## Unstaged Edits 2020-02-14 22:04:42 +09:00
SI
c593b5ede3 Translate ## Staging 2020-02-14 21:35:05 +09:00
SI
5d1814a388 Translate ## Editing Commits 2020-02-13 23:52:53 +09:00
SI
a9acfde034 Elaborate ## Repositories 2020-02-13 19:29:45 +09:00
SI
73f711331e Translate ##Repositories 2020-02-13 14:04:44 +09:00
79584f5e20 initialize ja 2020-02-13 12:13:04 +09:00
4afbb4e710 fix typo in 'скомпромЕтированныМ' (#292)
https://ru.wiktionary.org/wiki/%D1%81%D0%BA%D0%BE%D0%BC%D0%BF%D1%80%D0%BE%D0%BC%D0%B5%D1%82%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D1%82%D1%8C
2020-01-17 10:02:24 -05:00
76308321b0 add note on updating remote branch name (#290)
* add note on updating remote branch name

* Style edits.
2019-11-11 07:50:37 -05:00
bce2f0dd27 Note/git add u (#287)
* add note about 'git add -u '

* run doctoc

* add note about copying folder

* add space b/w -- and folder name

also mention, this can be done for files

* add 'file' in the title

* add node on using pathspec

* run doctoc

* fix small errors

* run doctoc

* remove 'my-branch' text
2019-10-30 08:38:19 -04:00
f0b433773f add note about copying folder (#289)
* add note about copying folder

* add space b/w -- and folder name

also mention, this can be done for files

* add 'file' in the title
2019-10-20 13:38:02 +02:00
e0ff2c06b9 update Russian translation (#286) 2019-10-15 11:24:03 +00:00
40a542d31a English language edits 2019-09-30 08:50:18 -04:00
f1a2195372 add note about git stash pop --index 0 2019-09-20 05:43:05 +00:00
4252773598 fix git stash push 2019-09-12 01:12:30 +00:00
260a140bda fix case: switch stage & unstage files 2019-09-11 05:01:59 +00:00
5c57fb5ea5 fix typo 2019-09-10 03:37:36 +00:00
896006ff4d Optimize and fill operation about git stash 2019-09-09 06:09:11 +00:00
241437d1fe Fixes some spelling mistakes. (#283)
* url -> URL

https://dictionary.cambridge.org/dictionary/english/url

* Added article

* Added article

* Remove comma before and

* other -> another

* Add missing determiner

* lastet -> latest

https://dictionary.cambridge.org/dictionary/english/latest

* succeeeds -> succeeds

https://dictionary.cambridge.org/dictionary/english/succeed

* commited -> committed

* Update toc via doctoc
2019-09-06 12:30:46 -04:00
Wei
1cef8c2032 Improve the first sentence in Zh translation (#281) 2019-09-06 12:30:06 -04:00
16f81ed7b0 Added a nasa book (#278) 2019-09-06 12:28:09 -04:00
79c67f674e Fixes to #274 (#275)
* added contribute other people repositories section

* fix: Edits to #274

* Update README.md

Co-Authored-By: Diego Sanchez <diegogsann@gmail.com>

* Update README.md

Co-Authored-By: Diego Sanchez <diegogsann@gmail.com>

* Update README.md

Co-Authored-By: Diego Sanchez <diegogsann@gmail.com>
2019-06-20 11:40:46 +02:00
ad141eeeb6 Added a guide to removing large files from repo history using bfg (#249)
* Explanation of removing large files using bfg

* doctoc applied to removing large files guide

* Remove large files: clean up wording

* Add subheadings to the large file removal section in preparation for git-filter-branch explanation

* large file removal: clean up headings

* large file removal: force push considerations note

* Add word "private" to sensitive data section for searchability

* Finish git-filter-branch instructions

* Minor grammatical changes and simplifications.
2019-06-05 10:53:00 -04:00
a545b0851d Remove broken link to nasa pdf doc. (#271) 2019-05-31 23:53:50 -04:00
ff548e28d8 Updates TOC (#273) 2019-05-31 23:53:34 -04:00
d3ac210fe4 Add "Debugging with Git" (#266)
* Add "Debugging with Git"

* Fix spelling error
2019-05-28 21:45:17 -04:00
b14710acdf Update Russian translation (#270) 2019-05-28 10:22:04 -04:00
d4cf0fb88a Allows SSL errors in links (#265)
Fixes #264
2019-01-30 10:11:55 +02:00
8e697833ae Add shortcuts information for Windows PowerShell (#263) 2018-12-11 12:29:13 -05:00
73547ca942 Add pcottle/learnGitBranching (#262) 2018-12-06 14:12:33 -05:00
3d6c00dded Git shortcuts (#261)
* I committed and pushed a merge that shouldn't have happened

* git shortcuts

* remove extra commands in git shortcut section
2018-12-06 14:12:13 -05:00
8b09e3fb58 Slight wording changes 2018-12-06 09:55:45 -05:00
5cfcca513c Add section on reset -p to unstage edits
Expanded  explanation & corrected bad grammar.
2018-12-06 09:55:42 -05:00
b67b184d8a Merge branch 'nzachow-master' 2018-11-29 14:17:40 -05:00
ee10f43326 Adding a period. 2018-11-29 14:17:35 -05:00
0d109a7f9c Merge branch 'm007-master' 2018-11-29 14:12:12 -05:00
1877d108b0 Small wording changes 2018-11-29 14:12:07 -05:00
42b5519891 Wording improvements due to review comments
Like discussed in the PR this commit improves the quested section
regarding lesser spelling mistakes and improved wording. The discussion
about --no-edit lead to no changes required, so it is not altered.

See https://github.com/k88hudson/git-flight-rules/pull/256
2018-11-29 20:00:27 +01:00
9d16c95ee1 Adds a few useful git aliases (#258)
Addresses #225
2018-11-29 11:28:21 -05:00
c9cfb71843 README_fr.md - replacing weird characters (#259)
Thanks for the translation!
2018-11-29 11:26:58 -05:00
4b5cad207a Use npm scripts for travis commands 2018-11-28 09:07:46 -05:00
db69499594 Ran doctoc again 2018-11-28 09:07:38 -05:00
7cb8c1a105 Merge branch 'grantslone-master' 2018-11-28 08:56:04 -05:00
bbcb8f6704 Small grammar edits 2018-11-28 08:56:01 -05:00
8854c326b9 Merge branch 'retiform-master' 2018-11-28 08:48:05 -05:00
d6e98fd537 Small spelling and style changes 2018-11-28 08:47:50 -05:00
bd388a89c5 Update README.md 2018-11-27 23:01:22 -05:00
ca49abe067 Update README.md 2018-11-27 23:00:21 -05:00
8809567e7a Update README.md 2018-11-27 22:59:54 -05:00
9b54d14dff Update README.md 2018-11-27 22:57:52 -05:00
066cf428e1 Update README.md 2018-11-27 22:56:06 -05:00
a3ece44263 add french (fr) translation (#252) 2018-11-27 14:43:27 -05:00
911089c406 Update README_kr.md (#257)
edit typo 🇰🇷
2018-11-27 12:12:13 -05:00
ebfe5dae13 Add section on how to modify an arbitrary commit
Explain how to solve situations where you want to modify a commit which
is not your last by using interactive rebase.
2018-11-20 18:16:58 +01:00
4b6e19a5ea Fix typo (#254) 2018-11-14 18:28:44 -05:00
f4037ec5c1 Fix option to amend commit message (#255) 2018-11-14 18:28:28 -05:00
20e4b2c10d Merge branch 'hoannc54-master' 2018-11-14 07:42:46 -05:00
23e4b8d4f3 run doctoc 2018-11-14 07:42:26 -05:00
bd9af24828 update 2018-11-14 01:47:05 +07:00
bbbead4bcd add test 2 2018-11-12 23:52:23 +07:00
065ce6e742 add test 2018-11-12 23:48:53 +07:00
9d11cb4e9b update git readme vi 2018-11-12 22:57:45 +07:00
2e8a756862 update git 2018-11-11 00:09:55 +07:00
4e96f71c28 Fix typo in README_kr.md (#251)
글로버 -> 글로벌
2018-11-08 10:45:18 -05:00
ba88c82f94 added a section for unstaging a staged file. (#243)
I have accidentally staged many files in my working copy, and was looking for a way to unstage them by filename as I had some staged files that I wanted to keep. Didn't see anything that addressed my specific issue on the README, so thought of adding it here.
2018-11-04 16:35:56 -05:00
9e15db0d59 Update spanish README (#246) 2018-11-01 16:04:04 -04:00
57c4e3bc59 Corrected link label in the TOC for fixing Travis-CI (#239) 2018-10-30 04:20:29 -04:00
913e8285aa Update readme en (#242)
* added guide for amending sensitive data that was committed/pushed

* added formatting and more solutions for amending sensitive data

* added a few sentences to explain why any sensitive data should be considered compromised once it's been committed
2018-10-30 04:19:23 -04:00
9102de6186 Update Russian translation (#240) 2018-10-26 14:03:55 +02:00
efb35a9607 Telling Git to ignore a local change without unversioning the file (#219)
Ignoring local changes can be really handy for creds/credfile templates, I've found it particularly handy with Discord bot development where the configuration file can have an expected structure and expects you to add tokens to that config file
2018-10-24 19:15:19 +02:00
c767e4b22a Add rebase --onto details (#231) 2018-10-24 10:09:06 +02:00
f8257b615b Add guide to fix refspec multiple match error (#223)
* Add guide to working with tags and branches that share the same name.

Add the error scene when trying to push a tag/branch that share the same name and the commands to fix that problem.

* Fix formatting of an error statement.
2018-10-24 10:04:59 +02:00
8f4ec811b3 Added SublimeMerge client (#221)
Creators of Sublime Text recently launched a Git client, it has a lot of potential !

I think it has its place in this list 😃 

Please tell me if my phrasing is wrong
2018-10-23 17:02:23 +02:00
3339385cdb Fix typo in README_kr.md (#228)
* Fix typo in README_kr.md

fix following typo in korean readme:

Mecury -> Mercury
꺼에요 -> 거에요
꺼구요 -> 거구요
썻어 -> 썼어
썻고 -> 썼고
텍스트르 에디터 -> 텍스트 에디터
리에비스 -> 리베이스
쓼 수 -> 쓸 수
때떄로 -> 때때로
받을려면 -> 받으려면

* Update Doctoc ToC
2018-10-23 14:44:00 +02:00
02d9745c00 Add note about Git version (#217)
See #216. @ramiro how does this look?
2018-10-23 14:43:49 +02:00
965b320695 Add more resources to the list (#227)
* Add more tutorials to the list

* Add another book to the list
2018-10-23 14:42:23 +02:00
661024bc32 Fix links markdown formats in Spanish translation (#220) 2018-10-23 14:26:08 +02:00
1eb620d54c Make amend commands more specific (#218)
Previously, this document the same command for "I wrote the wrong thing in a commit message" and "I need to add staged changes to the previous commit". These are different operations! Now, the former has a command that only changes the commit message (without adding staged changes), and the latter has commands to add staged changes with or without updating the commit message.

I also added "reword" and "extend" aliases to the sample gitconfig for using the two pieces of `git commit --amend` separately.
2018-10-23 14:24:26 +02:00
0b7921c8d5 I want to view the evolution of a function 2018-10-17 23:07:16 -03:00
9bc656bdcc Added cred helper info 2018-10-17 15:28:13 -04:00
d988a3ab10 add instructions for what to do if you add the wrong remote 2018-10-17 13:42:42 -04:00
83261c5b7a Translate and add Korean (#215)
* make a readme

make a new readme for Korean

* git-flight-rule 번역 중간과정 01

브랜치 부분에서 한번 커밋

* git-flight-rule 번역 중간과정 02

머지 시작

* git-flight-rule 번역 1차 종료후 점검

* 점검 후 첫 완료

* 오타 수정 몇가지 수정

* 네비게이션 링크 추가

* 표현 수정
2018-09-13 14:20:07 -04:00
c2ffba97eb I committed and pushed a merge that shouldn't have happened (#213) 2018-07-17 17:59:17 -04:00
8cfa8e476a Translate README_ru.md via GitLocalize (#210) 2018-07-09 16:50:20 -04:00
df439158b4 fix link 2018-06-14 10:40:04 -04:00
29a9c7cbca Rename README-es.md and add link to it from README.md (#212)
When viewing the git-flight-rules repository under gitlab, it lists the first README*.md file, which for some reason it sorts `-` before `.`.  This changes the Spanish README's filename to match the other two translations already in this repository.
2018-06-14 10:35:18 -04:00
a06bef415e Add spanish translation (#119) 2018-05-14 12:40:45 -04:00
42472aaa94 Remove unnecessary tag 2018-05-14 12:37:08 -04:00
0f16ad1e2d Issue #194 - Snippet to list changes (diff) of a specific file between two commits (or branches) 2018-05-14 12:37:08 -04:00
4f3582494d Incorporate Git Cheatsheet (#174)
* Adding Git Cheatsheet commands

This is an example of how #90 should be done.

* Move other configuration commands

* Move configuration
2018-05-14 12:35:33 -04:00
4d42bb9070 Fix rule "i-want-to-create-a-new-remote-branch-from-current-local-one" (#208)
* Add missing HEAD argument in 2 Git commands

These commands had been inserted in #148 and (over)simplified in #163.

The issue is that `git push <remote>` and `git push -u <remote>` will
typically raise the error below (unlike `git push <remote> HEAD`):

--8<---------------cut here---------------start------------->8---
fatal: The current branch new-branch has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin new-branch
--8<---------------cut here---------------end--------------->8---

* Add doc URL & Avoid triple backquotes
2018-02-20 15:14:13 -04:00
d8c55ae8c5 Fix misspelling (#206) 2018-02-05 09:01:13 -04:00
14ea0820c8 Added test for TOC to .travis.yml (#205)
Runs doctoc for README*.md.
If in newly doctoc'ed README*.md there are any diffs against
ones commited in git HEAD then the test failes.
The script are using the latest anchor-markdown-header from repo
to avoid the bug with non-ASCII headers.
2018-01-13 22:00:59 -05:00
ea40bf75ca Translate README_ru.md via GitLocalize (#203) 2018-01-11 08:57:04 -05:00
fb27b20f1f Remove unnecessary anchor tags (#200) 2018-01-07 10:47:23 -05:00
e0513d81c2 I made changes to the wrong branch (#202)
* I made changes to the wrong branch

* Missed from last commit

* Fixing links

* Making changes

* Another change

* Moving section
2018-01-07 10:46:31 -05:00
be480c4c35 Merge pull request #201 from carusogabriel/patch-1
Possible mistake
2018-01-02 09:19:18 -03:00
3f85b185de Possible mistake 2018-01-02 07:30:25 -02:00
f9792e9c68 Clean up READMEs (#198)
Signed-off-by: Gabriel Caruso <carusogabriel34@gmail.com>
2018-01-01 11:40:52 -06:00
590f63c7e6 Add colon 2017-12-30 12:26:44 -06:00
5de8869df2 Add a way to find tags containing specific commit (#195)
* Add a way to find tags containing specific commit

* fixup! Add a way to find tags containing specific commit
2017-12-30 13:21:53 -05:00
4dcb631734 Including snippet to list commits containing specific files (#197) 2017-12-30 12:57:11 -05:00
e4e6ee08b1 Add "I want to delete multiple branches" (#196) 2017-12-30 12:25:11 -05:00
26138f0f10 Fixed typo in git branch -rr invocation (#190) 2017-12-29 09:52:07 -05:00
68820c1dc3 Auto-check for translated pages README_*.md with Travis CI (#188) 2017-12-23 10:51:19 -05:00
84322067fe Updated Russian translations (#187) 2017-12-23 10:50:23 -05:00
7dc4eedb17 Removing -x on git clean tip to avoid unintentional use (#186)
* Removing -x on git clean to avoid unintentionally use

* Removing ! on git clean tip
2017-12-22 10:43:25 -05:00
697dbb404f Update CONTRIBUTE.md (#185)
gitlocalize repository url
2017-12-22 09:41:14 -05:00
423eaf0ede Merge pull request #183 from sotayamashita/feature/validate-links
Add travis config to validate links
2017-12-21 14:07:29 -05:00
ae8459b6da Missed this grammar bit 2017-12-20 20:39:16 -05:00
3966d41462 Add translation section to contributing (#179)
* Add translation section to contributing

* Update CONTRIBUTE.md

* Update CONTRIBUTE.md

* Update CONTRIBUTE.md
2017-12-20 20:38:10 -05:00
ca04c4bfb4 Added the Atlassian Git tutorial site (#181) 2017-12-20 16:08:19 -05:00
58fab97420 Fixed the typo for Sourcetree and updated the description (#180) 2017-12-19 22:12:56 -05:00
c91d1081c4 Add travis config to calidate links 2017-12-20 11:34:49 +09:00
e5039cc2b9 Rename zh-CN translation to be compatible with GitLocalize (#178) 2017-12-19 19:47:46 -05:00
f462bad54d Add examples from the common screwups resource in #40 (#175)
* Adding submodule section

* Add the rest of the commands
2017-12-19 19:47:30 -05:00
13 changed files with 12856 additions and 460 deletions

2
.gitignore vendored Normal file
View File

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

11
.travis.yml Normal file
View 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

View File

@ -26,3 +26,21 @@ This is a community built document. Dive in and help out!
```sh
(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

1060
README.md

File diff suppressed because it is too large Load Diff

1452
README_es.md Normal file

File diff suppressed because it is too large Load Diff

1637
README_fr.md Normal file

File diff suppressed because it is too large Load Diff

2174
README_ja.md Normal file

File diff suppressed because it is too large Load Diff

1580
README_kr.md Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

2109
README_vi.md Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
# 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-TW.md) ∙ [简体中文](README_zh-CN.md) ∙ [한국어](README_kr.md) ∙ [Tiếng Việt](README_vi.md) ∙ [Français](README_fr.md) ∙ [日本語](README_ja.md)*
#### 前言
@ -10,7 +10,7 @@
#### 什么是"飞行规则"?
一个 [宇航员指南](http://www.jsc.nasa.gov/news/columbia/fr_generic.pdf) (现在, 程序员们都在使用GIT) 是关于出现问题过后应该怎么操作
这是一篇给宇航员这里就是指使用Git的程序员们的指南用来指导问题出现后的应对之法
> *飞行规则(Flight Rules)* 是记录在手册上的来之不易的一系列知识,记录了某个事情发生的原因,以及怎样一步一步的进行处理。本质上, 它们是特定场景的非常详细的标准处理流程。 [...]
@ -32,7 +32,7 @@
- [我的提交信息(commit message)写错了](#%E6%88%91%E7%9A%84%E6%8F%90%E4%BA%A4%E4%BF%A1%E6%81%AFcommit-message%E5%86%99%E9%94%99%E4%BA%86)
- [我提交(commit)里的用户名和邮箱不对](#%E6%88%91%E6%8F%90%E4%BA%A4commit%E9%87%8C%E7%9A%84%E7%94%A8%E6%88%B7%E5%90%8D%E5%92%8C%E9%82%AE%E7%AE%B1%E4%B8%8D%E5%AF%B9)
- [我想从一个提交(commit)里移除一个文件](#%E6%88%91%E6%83%B3%E4%BB%8E%E4%B8%80%E4%B8%AA%E6%8F%90%E4%BA%A4commit%E9%87%8C%E7%A7%BB%E9%99%A4%E4%B8%80%E4%B8%AA%E6%96%87%E4%BB%B6)
- [我想删除我的最后一次提交(commit)](#%E6%88%91%E6%83%B3%E5%88%A0%E9%99%A4%E6%88%91%E7%9A%84%E7%9A%84%E6%9C%80%E5%90%8E%E4%B8%80%E6%AC%A1%E6%8F%90%E4%BA%A4commit)
- [我想删除我的最后一次提交(commit)](#%E6%88%91%E6%83%B3%E5%88%A0%E9%99%A4%E6%88%91%E7%9A%84%E7%9A%84%E6%9C%80%E5%90%8E%E4%B8%80%E6%AC%A1%E6%8F%90%E4%BA%A4commit)
- [删除任意提交(commit)](#%E5%88%A0%E9%99%A4%E4%BB%BB%E6%84%8F%E6%8F%90%E4%BA%A4commit)
- [我尝试推一个修正后的提交(amended commit)到远程,但是报错:](#%E6%88%91%E5%B0%9D%E8%AF%95%E6%8E%A8%E4%B8%80%E4%B8%AA%E4%BF%AE%E6%AD%A3%E5%90%8E%E7%9A%84%E6%8F%90%E4%BA%A4amended-commit%E5%88%B0%E8%BF%9C%E7%A8%8B%E4%BD%86%E6%98%AF%E6%8A%A5%E9%94%99)
- [我意外的做了一次硬重置(hard reset),我想找回我的内容](#%E6%88%91%E6%84%8F%E5%A4%96%E7%9A%84%E5%81%9A%E4%BA%86%E4%B8%80%E6%AC%A1%E7%A1%AC%E9%87%8D%E7%BD%AEhard-reset%E6%88%91%E6%83%B3%E6%89%BE%E5%9B%9E%E6%88%91%E7%9A%84%E5%86%85%E5%AE%B9)
@ -49,7 +49,7 @@
- [分支(Branches)](#%E5%88%86%E6%94%AFbranches)
- [我从错误的分支拉取了内容,或把内容拉取到了错误的分支](#%E6%88%91%E4%BB%8E%E9%94%99%E8%AF%AF%E7%9A%84%E5%88%86%E6%94%AF%E6%8B%89%E5%8F%96%E4%BA%86%E5%86%85%E5%AE%B9%E6%88%96%E6%8A%8A%E5%86%85%E5%AE%B9%E6%8B%89%E5%8F%96%E5%88%B0%E4%BA%86%E9%94%99%E8%AF%AF%E7%9A%84%E5%88%86%E6%94%AF)
- [我想扔掉本地的提交(commit),以便我的分支与远程的保持一致](#%E6%88%91%E6%83%B3%E6%89%94%E6%8E%89%E6%9C%AC%E5%9C%B0%E7%9A%84%E6%8F%90%E4%BA%A4commit%E4%BB%A5%E4%BE%BF%E6%88%91%E7%9A%84%E5%88%86%E6%94%AF%E4%B8%8E%E8%BF%9C%E7%A8%8B%E7%9A%84%E4%BF%9D%E6%8C%81%E4%B8%80%E8%87%B4)
- [我需要提交到一个新分支但错误的提交到了master](#%E6%88%91%E9%9C%80%E8%A6%81%E6%8F%90%E4%BA%A4%E5%88%B0%E4%B8%80%E4%B8%AA%E6%96%B0%E5%88%86%E6%94%AF%E4%BD%86%E9%94%99%E8%AF%AF%E7%9A%84%E6%8F%90%E4%BA%A4%E5%88%B0%E4%BA%86master)
- [我需要提交到一个新分支但错误的提交到了main](#%E6%88%91%E9%9C%80%E8%A6%81%E6%8F%90%E4%BA%A4%E5%88%B0%E4%B8%80%E4%B8%AA%E6%96%B0%E5%88%86%E6%94%AF%E4%BD%86%E9%94%99%E8%AF%AF%E7%9A%84%E6%8F%90%E4%BA%A4%E5%88%B0%E4%BA%86main)
- [我想保留来自另外一个ref-ish的整个文件](#%E6%88%91%E6%83%B3%E4%BF%9D%E7%95%99%E6%9D%A5%E8%87%AA%E5%8F%A6%E5%A4%96%E4%B8%80%E4%B8%AAref-ish%E7%9A%84%E6%95%B4%E4%B8%AA%E6%96%87%E4%BB%B6)
- [我把几个提交(commit)提交到了同一个分支,而这些提交应该分布在不同的分支里](#%E6%88%91%E6%8A%8A%E5%87%A0%E4%B8%AA%E6%8F%90%E4%BA%A4commit%E6%8F%90%E4%BA%A4%E5%88%B0%E4%BA%86%E5%90%8C%E4%B8%80%E4%B8%AA%E5%88%86%E6%94%AF%E8%80%8C%E8%BF%99%E4%BA%9B%E6%8F%90%E4%BA%A4%E5%BA%94%E8%AF%A5%E5%88%86%E5%B8%83%E5%9C%A8%E4%B8%8D%E5%90%8C%E7%9A%84%E5%88%86%E6%94%AF%E9%87%8C)
- [我想删除上游(upstream)分支被删除了的本地分支](#%E6%88%91%E6%83%B3%E5%88%A0%E9%99%A4%E4%B8%8A%E6%B8%B8upstream%E5%88%86%E6%94%AF%E8%A2%AB%E5%88%A0%E9%99%A4%E4%BA%86%E7%9A%84%E6%9C%AC%E5%9C%B0%E5%88%86%E6%94%AF)
@ -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 编辑屏幕出现'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)
- [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)
- [克隆所有子模块](#%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)
@ -87,7 +93,6 @@
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
## 编辑提交(editting commits)
<a name="diff-last"></a>
@ -96,7 +101,7 @@
如果你用 `git commit -a` 提交了一次变化(changes),而你又不确定到底这次提交了哪些内容。 你就可以用下面的命令显示当前`HEAD`上的最近一次的提交(commit):
```sh
(master)$ git show
(main)$ git show
```
或者
@ -105,18 +110,18 @@
$ git log -n1 -p
```
<a name="#i-wrote-the-wrong-thing-in-a-commit-message"></a>
<a name="wrong-thing-in-commit-message"></a>
### 我的提交信息(commit message)写错了
如果你的提交信息(commit message)写错了且这次提交(commit)还没有推(push), 你可以通过下面的方法来修改提交信息(commit message):
```sh
$ git commit --amend
$ git commit --amend --only
```
这会打开你的默认编辑器, 在这里你可以编辑信息. 另一方面, 你也可以用一条命令一次完成:
```sh
$ git commit --amend -m 'xxxxxxx'
$ git commit --amend --only -m 'xxxxxxx'
```
如果你已经推(push)了这次提交(commit), 你可以修改这次提交(commit)然后强推(force push), 但是不推荐这么做。
@ -132,8 +137,7 @@ $ git commit --amend --author "New Authorname <authoremail@mydomain.com>"
如果你需要修改所有历史, 参考 'git filter-branch'的指南页.
<a href="#i-want-to-remove-a-file-from-a-commit"></a>
<a name="remove-file-from-commit"></a>
### 我想从一个提交(commit)里移除一个文件
通过下面的方法,从一个提交(commit)里移除一个文件:
@ -159,8 +163,7 @@ $ git push -f [remote] [branch]
如果你还没有推到远程, 把Git重置(reset)到你最后一次提交前的状态就可以了(同时保存暂存的变化):
```
(my-branch*)$ git reset --soft HEAD@{1}
(my-branch)$ git reset --soft HEAD^
```
这只能在没有推送之前有用. 如果你已经推了, 唯一安全能做的是 `git revert SHAofBadCommit` 那会创建一个新的提交(commit)用于撤消前一个提交的所有变化(changes) 或者, 如果你推的这个分支是rebase-safe的 (例如: 其它开发者不会从这个分支拉), 只需要使用 `git push -f` 更多, 请参考 [the above section](#deleteremove-last-pushed-commit)。
@ -177,7 +180,7 @@ $ git push -f [remote] [branch]
或者做一个 [交互式rebase](#interactive-rebase) 删除那些你想要删除的提交(commit)里所对应的行。
<a name="#force-push"></a>
<a name="force-push"></a>
### 我尝试推一个修正后的提交(amended commit)到远程,但是报错:
```sh
@ -198,26 +201,26 @@ hint: See the 'Note about fast-forwards' in 'git push --help' for details.
一般来说, **要避免强推**. 最好是创建和推(push)一个新的提交(commit),而不是强推一个修正后的提交。后者会使那些与该分支或该分支的子分支工作的开发者,在源历史中产生冲突。
<a href="undo-git-reset-hard"></a>
<a name="undo-git-reset-hard"></a>
### 我意外的做了一次硬重置(hard reset),我想找回我的内容
如果你意外的做了 `git reset --hard`, 你通常能找回你的提交(commit), 因为Git对每件事都会有日志且都会保存几天。
```sh
(master)$ git reflog
(main)$ git reflog
```
你将会看到一个你过去提交(commit)的列表, 和一个重置的提交。 选择你想要回到的提交(commit)的SHA再重置一次:
```sh
(master)$ git reset --hard SHA1234
(main)$ git reset --hard SHA1234
```
这样就完成了。
## 暂存(Staging)
<a href="#i-need-to-add-staged-changes-to-the-previous-commit"></a>
<a name="add-staged-changes-to-previous-commit"></a>
### 我需要把暂存的内容添加到上一次的提交(commit)
```sh
@ -242,35 +245,38 @@ $ git add -N filename.x
然后, 你需要用 `e` 选项来手动选择需要添加的行,执行 `git diff --cached` 将会显示哪些行暂存了哪些行只是保存在本地了。
<a href="stage-in-two-commits"></a>
<a name="stage-in-two-commits"></a>
### 我想把在一个文件里的变化(changes)加到两个提交(commit)里
`git add` 会把整个文件加入到一个提交. `git add -p` 允许交互式的选择你想要提交的部分.
<a href="unstaging-edits-and-staging-the-unstaged"></a>
<a name="unstaging-edits-and-staging-the-unstaged"></a>
### 我想把暂存的内容变成未暂存,把未暂存的内容暂存起来
这个有点困难, 我能想到的最好的方法是先stash未暂存的内容 然后重置(reset)再pop第一步stashed的内容, 最后再add它们
多数情况下你应该将所有的内容变为未暂存然后再选择你想要的内容进行commit
但假定你就是想要这么做这里你可以创建一个临时的commit来保存你已暂存的内容然后暂存你的未暂存的内容并进行stash。然后reset最后一个commit将原本暂存的内容变为未暂存最后stash pop回来。
```sh
$ git stash -k
$ git reset --hard
$ git stash pop
$ git add -A
$ git commit -m "WIP"
$ git add .
$ git stash
$ 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时加indexgit会把两个一起销毁所以staged里就空了
## 未暂存(Unstaged)的内容
<a href="move-unstaged-edits-to-new-branch"></a>
<a name="move-unstaged-edits-to-new-branch"></a>
### 我想把未暂存的内容移动到一个新分支
```sh
$ git checkout -b my-branch
```
<a href="move-unstaged-edits-to-old-branch"></a>
<a name="move-unstaged-edits-to-old-branch"></a>
### 我想把未暂存的内容移动到另一个已存在的分支
```sh
@ -279,7 +285,7 @@ $ git checkout my-branch
$ git stash pop
```
<a href="i-want-to-discard-my-local-uncommitted-changes"></a>
<a name="discard-local-uncommitted-changes"></a>
### 我想丢弃本地未提交的变化(uncommitted changes)
如果你只是想重置源(origin)和你本地(local)之间的一些提交(commit),你可以:
@ -292,7 +298,7 @@ $ git stash pop
# four commits
(my-branch)$ git reset --hard HEAD~4
# or
(master)$ git checkout -f
(main)$ git checkout -f
```
重置某个特殊的文件, 你可以用文件名做为参数:
@ -301,7 +307,7 @@ $ git stash pop
$ git reset filename
```
<a href="i-want-to-discard-specific-unstaged-changes"></a>
<a name="discard-specific-unstaged-changes"></a>
### 我想丢弃某些未暂存的内容
如果你想丢弃工作拷贝中的一部分内容,而不是全部。
@ -338,7 +344,7 @@ $ git stash drop
这是另外一种使用 `git reflog` 情况,找到在这次错误拉(pull) 之前HEAD的指向。
```sh
(master)$ git reflog
(main)$ git reflog
ab7555f HEAD@{0}: pull origin wrong-branch: Fast-forward
c5bc55a HEAD@{1}: checkout: checkout message goes here
```
@ -351,7 +357,7 @@ $ git reset --hard c5bc55a
完成。
<a href="discard-local-commits"></a>
<a name="discard-local-commits"></a>
### 我想扔掉本地的提交(commit),以便我的分支与远程的保持一致
先确认你没有推(push)你的内容到远程。
@ -369,39 +375,39 @@ $ git reset --hard c5bc55a
一种方法是:
```sh
(master)$ git reset --hard origin/my-branch
(my-branch)$ git reset --hard origin/my-branch
```
<a name="commit-wrong-branch"></a>
### 我需要提交到一个新分支但错误的提交到了master
### 我需要提交到一个新分支但错误的提交到了main
在master下创建一个新分支,不切换到新分支,仍在master下:
在main下创建一个新分支,不切换到新分支,仍在main下:
```sh
(master)$ git branch my-branch
(main)$ git branch my-branch
```
把master分支重置到前一个提交:
把main分支重置到前一个提交:
```sh
(master)$ git reset --hard HEAD^
(main)$ git reset --hard HEAD^
```
`HEAD^``HEAD^1` 的简写,你可以通过指定要设置的`HEAD`来进一步重置。
或者, 如果你不想使用 `HEAD^`, 找到你想重置到的提交(commit)的hash(`git log` 能够完成) 然后重置到这个hash。 使用`git push` 同步内容到远程。
例如, master分支想重置到的提交的hash为`a13b85e`:
例如, main分支想重置到的提交的hash为`a13b85e`:
```sh
(master)$ git reset --hard a13b85e
(main)$ git reset --hard a13b85e
HEAD is now at a13b85e
```
签出(checkout)刚才新建的分支继续工作:
```sh
(master)$ git checkout my-branch
(main)$ git checkout my-branch
```
<a name="keep-whole-file"></a>
@ -444,10 +450,10 @@ Note: Spike solutions are made to analyze or solve the problem. These solutions
<a name="cherry-pick"></a>
### 我把几个提交(commit)提交到了同一个分支,而这些提交应该分布在不同的分支里
假设你有一个`master`分支, 执行`git log`, 你看到你做过两次提交:
假设你有一个`main`分支, 执行`git log`, 你看到你做过两次提交:
```sh
(master)$ git log
(main)$ git log
commit e3851e817c451cc36f2e6f3049db528415e3c114
Author: Alex Lee <alexlee@example.com>
@ -470,17 +476,17 @@ Date: Tue Jul 21 01:12:48 2014 -0400
让我们用提交hash(commit hash)标记bug (`e3851e8` for #21, `5ea5173` for #14).
首先, 我们把`master`分支重置到正确的提交(`a13b85e`):
首先, 我们把`main`分支重置到正确的提交(`a13b85e`):
```sh
(master)$ git reset --hard a13b85e
(main)$ git reset --hard a13b85e
HEAD is now at a13b85e
```
现在, 我们对 bug #21 创建一个新的分支:
```sh
(master)$ git checkout -b 21
(main)$ git checkout -b 21
(21)$
```
@ -492,12 +498,11 @@ HEAD is now at a13b85e
这时候, 这里可能会产生冲突, 参见[交互式 rebasing 章](#interactive-rebase) [**冲突节**](#merge-conflict) 解决冲突.
再者, 我们为bug #14 创建一个新的分支, 也基于`master`分支
再者, 我们为bug #14 创建一个新的分支, 也基于`main`分支
```sh
(21)$ git checkout master
(master)$ git checkout -b 14
(21)$ git checkout main
(main)$ git checkout -b 14
(14)$
```
@ -507,7 +512,6 @@ HEAD is now at a13b85e
(14)$ git cherry-pick 5ea5173
```
<a name="delete-stale-local-branches"></a>
### 我想删除上游(upstream)分支被删除了的本地分支
一旦你在github 上面合并(merge)了一个pull request, 你就可以删除你fork里被合并的分支。 如果你不准备继续在这个分支里工作, 删除这个分支的本地拷贝会更干净,使你不会陷入工作分支和一堆陈旧分支的混乱之中。
@ -516,13 +520,13 @@ HEAD is now at a13b85e
$ git fetch -p
```
<a name='restore-a-deleted-branch'></a>
<a name="restore-a-deleted-branch"></a>
### 我不小心删除了我的分支
如果你定期推送到远程, 多数情况下应该是安全的,但有些时候还是可能删除了还没有推到远程的分支。 让我们先创建一个分支和一个新的文件:
```sh
(master)$ git checkout -b my-branch
(main)$ git checkout -b my-branch
(my-branch)$ git branch
(my-branch)$ touch foo.txt
(my-branch)$ ls
@ -552,31 +556,31 @@ Date: Tue Jul 29 13:14:46 2014 -0400
Fixes #6: Force pushing after amending commits
```
现在我们切回到主(master)分支,‘不小心的’删除`my-branch`分支
现在我们切回到主(main)分支,‘不小心的’删除`my-branch`分支
```sh
(my-branch)$ git checkout master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
(master)$ git branch -D my-branch
(my-branch)$ git checkout main
Switched to branch 'main'
Your branch is up-to-date with 'origin/main'.
(main)$ git branch -D my-branch
Deleted branch my-branch (was 4e3cd85).
(master)$ echo oh noes, deleted my branch!
(main)$ echo oh noes, deleted my branch!
oh noes, deleted my branch!
```
在这时候你应该想起了`reflog`, 一个升级版的日志,它存储了仓库(repo)里面所有动作的历史。
```
(master)$ git reflog
69204cd HEAD@{0}: checkout: moving from my-branch to master
(main)$ git reflog
69204cd HEAD@{0}: checkout: moving from my-branch to main
4e3cd85 HEAD@{1}: commit: foo.txt added
69204cd HEAD@{2}: checkout: moving from master to my-branch
69204cd HEAD@{2}: checkout: moving from main to my-branch
```
正如你所见我们有一个来自删除分支的提交hash(commit hash),接下来看看是否能恢复删除了的分支。
```sh
(master)$ git checkout -b my-branch-help
(main)$ git checkout -b my-branch-help
Switched to a new branch 'my-branch-help'
(my-branch-help)$ git reset --hard 4e3cd85
HEAD is now at 4e3cd85 foo.txt added
@ -586,40 +590,40 @@ README.md foo.txt
看! 我们把删除的文件找回来了。 Git的 `reflog` 在rebasing出错的时候也是同样有用的。
<a name="i-want-to-delete-a-branch"></a>
<a name="delete-branch"></a>
### 我想删除一个分支
删除一个远程分支:
```sh
(master)$ git push origin --delete my-branch
(main)$ git push origin --delete my-branch
```
你也可以:
```sh
(master)$ git push origin :my-branch
(main)$ git push origin :my-branch
```
删除一个本地分支:
```sh
(master)$ git branch -D my-branch
(main)$ git branch -D my-branch
```
<a name="i-want-to-checkout-to-a-remote-branch-that-someone-else-is-working-on"></a>
<a name="working-on-checkout-remote-branch"></a>
### 我想从别人正在工作的远程分支签出(checkout)一个分支
首先, 从远程拉取(fetch) 所有分支:
```sh
(master)$ git fetch --all
(main)$ git fetch --all
```
假设你想要从远程的`daves`分支签出到本地的`daves`
```sh
(master)$ git checkout --track origin/daves
(main)$ git checkout --track origin/daves
Branch daves set up to track remote branch daves from origin.
Switched to a new branch 'daves'
```
@ -645,10 +649,10 @@ Switched to a new branch 'daves'
不幸的是,如果你想把这些变化(changes)反应到远程分支上,你就必须得强推(force push)。 是因你快进(Fast forward)了提交改变了Git历史, 远程分支不会接受变化(changes),除非强推(force push)。这就是许多人使用 merge 工作流, 而不是 rebasing 工作流的主要原因之一, 开发者的强推(force push)会使大的团队陷入麻烦。使用时需要注意,一种安全使用 rebase 的方法是,不要把你的变化(changes)反映到远程分支上, 而是按下面的做:
```sh
(master)$ git checkout my-branch
(my-branch)$ git rebase -i master
(my-branch)$ git checkout master
(master)$ git merge --ff-only my-branch
(main)$ git checkout my-branch
(my-branch)$ git rebase -i main
(my-branch)$ git checkout main
(main)$ git merge --ff-only my-branch
```
更多, 参见 [this SO thread](http://stackoverflow.com/questions/11058312/how-can-i-use-git-rebase-without-requiring-a-forced-push).
@ -656,23 +660,23 @@ Switched to a new branch 'daves'
<a name="interactive-rebase"></a>
### 我需要组合(combine)几个提交(commit)
假设你的工作分支将会做对于 `master` 的pull-request。 一般情况下你不关心提交(commit)的时间戳,只想组合 *所有* 提交(commit) 到一个单独的里面, 然后重置(reset)重提交(recommit)。 确保主(master)分支是最新的和你的变化都已经提交了, 然后:
假设你的工作分支将会做对于 `main` 的pull-request。 一般情况下你不关心提交(commit)的时间戳,只想组合 *所有* 提交(commit) 到一个单独的里面, 然后重置(reset)重提交(recommit)。 确保主(main)分支是最新的和你的变化都已经提交了, 然后:
```sh
(my-branch)$ git reset --soft master
(my-branch)$ git reset --soft main
(my-branch)$ git commit -am "New awesome feature"
```
如果你想要更多的控制, 想要保留时间戳, 你需要做交互式rebase (interactive rebase):
```sh
(my-branch)$ git rebase -i master
(my-branch)$ git rebase -i main
```
如果没有相对的其它分支, 你将不得不相对自己的`HEAD` 进行 rebase。 例如:你想组合最近的两次提交(commit), 你将相对于`HEAD~2` 进行rebase 组合最近3次提交(commit), 相对于`HEAD~3`, 等等。
```sh
(master)$ git rebase -i HEAD~2
(main)$ git rebase -i HEAD~2
```
在你执行了交互式 rebase的命令(interactive rebase command)后, 你将在你的编辑器里看到类似下面的内容:
@ -732,7 +736,7 @@ Newer, awesomer features
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# rebase in progress; onto 8074d12
# You are currently editing a commit while rebasing branch 'master' on '8074d12'.
# You are currently editing a commit while rebasing branch 'main' on '8074d12'.
#
# Changes to be committed:
# modified: README.md
@ -743,20 +747,20 @@ Newer, awesomer features
如果成功了, 你应该看到类似下面的内容:
```sh
(master)$ Successfully rebased and updated refs/heads/master.
(main)$ Successfully rebased and updated refs/heads/main.
```
#### 安全合并(merging)策略
`--no-commit` 执行合并(merge)但不自动提交, 给用户在做提交前检查和修改的机会。 `no-ff` 会为特性分支(feature branch)的存在过留下证据, 保持项目历史一致。
```sh
(master)$ git merge --no-ff --no-commit my-branch
(main)$ git merge --no-ff --no-commit my-branch
```
#### 我需要将一个分支合并成一个提交(commit)
```sh
(master)$ git merge --squash my-branch
(main)$ git merge --squash my-branch
```
<a name="rebase-unpushed-commits"></a>
@ -765,7 +769,7 @@ Newer, awesomer features
有时候,在将数据推向上游之前,你有几个正在进行的工作提交(commit)。这时候不希望把已经推(push)过的组合进来,因为其他人可能已经有提交(commit)引用它们了。
```sh
(master)$ git rebase -i @{u}
(main)$ git rebase -i @{u}
```
这会产生一次交互式的rebase(interactive rebase), 只会列出没有推(push)的提交(commit) 在这个列表时进行reorder/fix/squash 都是安全的。
@ -776,13 +780,13 @@ Newer, awesomer features
检查一个分支上的所有提交(commit)是否都已经合并(merge)到了其它分支, 你应该在这些分支的head(或任何 commits)之间做一次diff:
```sh
(master)$ git log --graph --left-right --cherry-pick --oneline HEAD...feature/120-on-scroll
(main)$ git log --graph --left-right --cherry-pick --oneline HEAD...feature/120-on-scroll
```
这会告诉你在一个分支里有而另一个分支没有的所有提交(commit), 和分支之间不共享的提交(commit)的列表。 另一个做法可以是:
```sh
(master)$ git log master ^feature/120-on-scroll --no-merges
(main)$ git log main ^feature/120-on-scroll --no-merges
```
### 交互式rebase(interactive rebase)可能出现的问题
@ -797,7 +801,7 @@ noop
这意味着你rebase的分支和当前分支在同一个提交(commit)上, 或者 *领先(ahead)* 当前分支。 你可以尝试:
* 检查确保主(master)分支没有问题
* 检查确保主(main)分支没有问题
* rebase `HEAD~2` 或者更早
<a name="merge-conflict"></a>
@ -832,7 +836,7 @@ Changes not staged for commit:
有时候这些合并非常复杂,你应该使用可视化的差异编辑器(visual diff editor):
```sh
(master*)$ git mergetool -t opendiff
(main*)$ git mergetool -t opendiff
```
在你解决完所有冲突和测试过后, `git add` 变化了的(changed)文件, 然后用`git rebase --continue` 继续rebase。
@ -850,6 +854,82 @@ Changes not staged for commit:
(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 name="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>
## 杂项(Miscellaneous Objects)
@ -900,18 +980,18 @@ $ git update-ref refs/tags/<tag_name> <hash>
## 跟踪文件(Tracking Files)
<a href="i-want-to-change-a-file-names-capitalization-without-changing-the-contents-of-the-file"></a>
<a name="change-file-name-capitalization-without-changing-contents"></a>
### 我只想改变一个文件名字的大小写,而不修改内容
```sh
(master)$ git mv --force myfile MyFile
(main)$ git mv --force myfile MyFile
```
<a href="remove-from-git"></a>
<a name="remove-from-git"></a>
### 我想从Git删除一个文件但保留该文件
```sh
(master)$ git rm --cached log.txt
(main)$ git rm --cached log.txt
```
## 配置(Configuration)
@ -959,7 +1039,7 @@ $ git config --global credential.helper 'cache --timeout=3600'
# Set the cache to timeout after 1 hour (setting is in seconds)
```
<a href="#ive-no-idea-what-i-did-wrong"></a>
<a name="ive-no-idea-what-i-did-wrong"></a>
## 我不知道我做错了些什么
你把事情搞砸了:你 `重置(reset)` 了一些东西, 或者你合并了错误的分支, 亦或你强推了后找不到你自己的提交(commit)了。有些时候, 你一直都做得很好, 但你想回到以前的某个状态。
@ -967,25 +1047,24 @@ $ git config --global credential.helper 'cache --timeout=3600'
这就是 `git reflog` 的目的, `reflog` 记录对分支顶端(the tip of a branch)的任何改变, 即使那个顶端没有被任何分支或标签引用。基本上, 每次HEAD的改变, 一条新的记录就会增加到`reflog`。遗憾的是,这只对本地分支起作用,且它只跟踪动作 (例如,不会跟踪一个没有被记录的文件的任何改变)。
```sh
(master)$ git reflog
(main)$ git reflog
0a2e358 HEAD@{0}: reset: moving to HEAD~2
0254ea7 HEAD@{1}: checkout: moving from 2.2 to master
c10f740 HEAD@{2}: checkout: moving from master to 2.2
0254ea7 HEAD@{1}: checkout: moving from 2.2 to main
c10f740 HEAD@{2}: checkout: moving from main to 2.2
```
上面的reflog展示了从master分支签出(checkout)到2.2 分支,然后再签回。 那里,还有一个硬重置(hard reset)到一个较旧的提交。最新的动作出现在最上面以 `HEAD@{0}`标识.
上面的reflog展示了从main分支签出(checkout)到2.2 分支,然后再签回。 那里,还有一个硬重置(hard reset)到一个较旧的提交。最新的动作出现在最上面以 `HEAD@{0}`标识.
如果事实证明你不小心回移(move back)了提交(commit), reflog 会包含你不小心回移前master上指向的提交(0254ea7)。
如果事实证明你不小心回移(move back)了提交(commit), reflog 会包含你不小心回移前main上指向的提交(0254ea7)。
```sh
$ git reset --hard 0254ea7
```
然后使用git reset就可以把master改回到之前的commit这提供了一个在历史被意外更改情况下的安全网。
然后使用git reset就可以把main改回到之前的commit这提供了一个在历史被意外更改情况下的安全网。
([摘自](https://www.atlassian.com/git/tutorials/rewriting-history/git-reflog)).
# 其它资源(Other Resources)
## 书(Books)

1948
README_zh-TW.md Normal file

File diff suppressed because it is too large Load Diff

14
package.json Normal file
View 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"
}
}