k88hudson /git-flight-rules

Flight rules for git

★ 42,570⑂ 3,167👁 633⑃ 301● 73▤ 0
CC-BY-SA-4.0Created 2014-07-22
-2
Daily
-11
Weekly
42,570
stars
3,167
forks
633
watchers
301
prs
73
issues
0
releases

README

Flight rules for Git

🌍
English ∙ Español  ∙  Русский ∙ 繁體中文 ∙ 简体中文 ∙ 한국어  ∙  Tiếng Việt ∙ Français ∙ 日本語

 What are "flight rules"?

A guide for astronauts (now, programmers using Git) about what to do when things go wrong.

  Flight Rules are the hard-earned body of knowledge recorded in manuals that list, step-by-step, what to do if X occurs, and why. Essentially, they are extremely detailed, scenario-specific standard operating procedures. [...]

 NASA has been capturing our missteps, disasters and solutions since the early 1960s, when Mercury-era ground teams first started gathering "lessons learned" into a compendium that now lists thousands of problematic situations, from engine failure to busted hatch handles to computer glitches, and their solutions.

— Chris Hadfield, An Astronaut's Guide to Life on Earth.

 Conventions for this document

For clarity's sake all examples in this document use a customized bash prompt in order to indicate the current branch and whether or not there are staged changes. The branch is enclosed in parentheses, and a  next to the branch name indicates staged changes.

All commands should work for at least git version 2.13.0. See the git website to update your local git version.




Table of Contents  generated with DocToc

  - Repositories
    - I want to start a local repository
    - I want to clone a remote repository
    - I set the wrong remote repository
    - I want to add code to someone else's repository
      - Suggesting code via pull requests
      - Suggesting code via patches
      - I need to update my fork with latest updates from the original repository
  - Editing Commits
    - What did I just commit?
    - I wrote the wrong thing in a commit message
    - I committed with the wrong name and email configured
    - I want to remove a file from the previous commit
    - I want to move a change from one commit to another
    - I want to delete or remove my last commit
    - Delete/remove arbitrary commit
    - I tried to push my amended commit to a remote, but I got an error message
    - I accidentally did a hard reset, and I want my changes back
    - I accidentally committed and pushed a merge
    - I accidentally committed and pushed files containing sensitive data
    - I want to remove a large file from ever existing in repo history
      - Recommended Technique: Use third-party bfg
      - Built-in Technique: Use git-filter-branch
      - Final Step: Pushing your changed repo history
    - I need to change the content of a commit which is not my last
  - Staging
    - I want to stage all tracked files and leave untracked files
      - To stage part of tracked files
    - I want to stage all untracked files and leave tracked files
    - I need to add staged changes to the previous commit
    - I want to stage part of a new file, but not the whole file
    - I want to add changes in one file to two different commits
    - I staged too many edits, and I want to break them out into a sep

Top issues

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON