| Jul | AUG | Sep |
| 26 | ||
| 2020 | 2021 | 2022 |
COLLECTED BY
Collection: Wikipedia Eventstream
git --version
git *
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.
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].
git.git uses the following integration branches:
maint tracks the commits that should go into the next "maintenance
release", i.e., update of the last released stable version;
master tracks the commits that should go into the next release;
next is intended as a testing branch for topics being tested for
stability for master.
There is a fourth official branch that is used slightly differently:
seen (patches seen by the maintainer) is an integration branch for
things that are not quite ready for inclusion yet (see﹃Integration
Branches﹄below).
Each of the four branches is usually a direct descendant of the one
above it.
Conceptually, the feature enters at an unstable branch (usually nextorseen), and "graduates" to master for the next release once it is
considered stable enough.
git.git
has such an official throw-away integration branch called seen.
git log master..maint
This command should not list any commits. Otherwise, check out
master and merge maint into it.
Now you can proceed with the creation of the feature release. Apply a
tag to the tip of master indicating the release version:
Recipe: Release tagging
git tag -s -m "Git X.Y.Z" vX.Y.Z master
You need to push the new tag to a public Git server (see
"DISTRIBUTED WORKFLOWS" below). This makes the tag available to
others tracking your project. The push could also trigger a
post-update hook to perform release-related items such as building
release tarballs and preformatted documentation pages.
Similarly, for a maintenance release, maint is tracking the commits
to be released. Therefore, in the steps above simply tag and push
maint rather than master.
git branch maint-X.Y.(Z-1) maint
The maint branch should now be fast-forwarded to the newly released
code so that maintenance fixes can be tracked for the current release:
Recipe: Update maint to new release
git checkout maint
git merge --ff-only master
If the merge fails because it is not a fast-forward, then it is
possible some fixes on maint were missed in the feature release.
This will not happen if the content of the branches was verified as
described in the previous section.
git switch -C next master
git merge ai/topic_in_next1
git merge ai/topic_in_next2
…
The advantage of doing this is that the history of next will be
clean. For example, some topics merged into next may have initially
looked promising, but were later found to be undesirable or premature.
In such a case, the topic is reverted out of next but the fact
remains in the history that it was once merged and reverted. By
recreating next, you give another incarnation of such topics a clean
slate to retry, and a feature release is a good point in history to do
so.
If you do this, then you should make a public announcement indicating
that next was rewound and rebuilt.
The same rewind and rebuild process may be followed for seen. A public
announcement is not necessary since seen is a throw-away branch, as
described above.
git.git, only subsystem maintainers use
the merge workflow, while everyone else sends patches.
Note that the maintainer(s) may impose restrictions, such as
"Signed-off-by" requirements, that all commits/patches submitted for
inclusion must adhere to. Consult your project’s documentation for
more information.
git push <remote> <branch> and tell everyone where they can fetch
from.
You will still have to tell people by other means, such as mail. (Git
provides the git-request-pull[1] to send preformatted pull
requests to upstream maintainers to simplify this task.)
If you just want to get the newest copies of the integration branches,
staying up to date is easy too:
Recipe: Push/pull: Staying up to date
Use git fetch <remote>orgit remote update to stay up to date.
Then simply fork your topic branches from the stable remotes as
explained earlier.
If you are a maintainer and would like to merge other people’s topic
branches to the integration branches, they will typically send a
request to do so by mail. Such a request looks like
Please pull from
<url> <branch>
In that case, git pull can do the fetch and merge in one go, as
follows.
Recipe: Push/pull: Merging remote topics
git pull <url> <branch>
Occasionally, the maintainer may get merge conflicts when they try to
pull changes from downstream. In this case, they can ask downstream to
do the merge and resolve the conflicts themselves (perhaps they will
know better how to resolve them). It is one of the rare cases where
downstream should merge from upstream.
git format-patch -M upstream..topic to turn them into preformatted
patch files
git send-email --to=<recipient> <patches>
See the git-format-patch[1] and git-send-email[1]
manpages for further usage notes.
If the maintainer tells you that your patch no longer applies to the
current upstream, you will have to rebase your topic (you cannot use a
merge because you cannot format-patch merges):
Recipe: format-patch/am: Keeping topics up to date
git pull --rebase <url> <branch>
You can then fix the conflicts during the rebase. Presumably you have
not published your topic other than by mail, so rebasing it is not a
problem.
If you receive such a patch series (as maintainer, or perhaps as a
reader of the mailing list it was sent to), save the mails to files,
create a new topic branch and use git am to import the commits:
Recipe: format-patch/am: Importing patches
git am < patch
One feature worth pointing out is the three-way merge, which can help
if you get conflicts: git am -3 will use index information contained
in patches to figure out the merge base. See git-am[1] for
other options.