Setup and Config
Getting and Creating Projects
Basic Snapshotting
Branching and Merging
Sharing and Updating Projects
Inspection and Comparison
Patching
Debugging
External Systems
Server Admin
Guides
- gitattributes
- Command-line interface conventions
- Everyday Git
- Frequently Asked Questions (FAQ)
- Glossary
- Hooks
- gitignore
- gitmodules
- Revisions
- Submodules
- Tutorial
- Workflows
- All guides...
Administration
Plumbing Commands
- 2.35.1 → 2.55.0 no changes
-
2.35.0
2022-01-24
- 2.28.1 → 2.34.8 no changes
-
2.28.0
2020-07-27
- 2.23.1 → 2.27.1 no changes
-
2.23.0
2019-08-16
- 2.18.1 → 2.22.5 no changes
-
2.18.0
2018-06-21
- 2.17.0 → 2.17.6 no changes
-
2.16.6
2019-12-06
- 2.13.7 → 2.15.4 no changes
-
2.12.5
2017-09-22
- 2.1.4 → 2.11.4 no changes
-
2.0.5
2014-12-17
DESCRIPTION
This document attempts to write down and motivate some of the workflow
elements used for git.git itself. Many ideas apply in general,
though the full workflow is rarely required for smaller projects with
fewer people involved.
We formulate a set of rules for quick reference, while the prose tries to motivate each of them. Do not always take them literally; you should value good reasons for your actions higher than manpages such as this one.
SEPARATE CHANGES
As a general rule, you should try to split your changes into small logical steps, and commit each of them. They should be consistent, working independently of any later commits, pass the test suite, etc. This makes the review process much easier, and the history much more useful for later inspection and analysis, for example with git-blame[1] and git-bisect[1].
To achieve this, try to split your work into small steps from the very
beginning. It is always easier to squash a few commits together than
to split one big commit into several. Don’t be afraid of making too
small or imperfect steps along the way. You can always go back later
and edit the commits with git rebase --interactive before you
publish them. You can use git stash push --keep-index to run the
test suite independent of other uncommitted changes; see the EXAMPLES
section of git-stash[1].
MANAGING BRANCHES
There are two main tools that can be used to include changes from one branch on another: git-merge[1] and git-cherry-pick[1].
Merges have many advantages, so we try to solve as many problems as possible with merges alone. Cherry-picking is still occasionally useful; see "Merging upwards" below for an example.
Most importantly, merging works at the branch level, while cherry-picking works at the commit level. This means that a merge can carry over the changes from 1, 10, or 1000 commits with equal ease, which in turn means the workflow scales much better to a large number of contributors (and contributions). Merges are also easier to understand because a merge commit is a "promise" that all changes from all its parents are now included.
There is a tradeoff of course: merges require a more careful branch management. The following subsections discuss the important points.