|
Packit |
1470ea |
|
|
Packit |
1470ea |
<page xmlns="http://projectmallard.org/1.0/" xmlns:its="http://www.w3.org/2005/11/its" type="topic" id="version-control" xml:lang="de">
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<info>
|
|
Packit |
1470ea |
<link type="guide" xref="index#general-guidelines"/>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<credit type="author copyright">
|
|
Packit |
1470ea |
<name>Philip Withnall</name>
|
|
Packit |
1470ea |
<email its:translate="no">philip.withnall@collabora.co.uk</email>
|
|
Packit |
1470ea |
<years>2015</years>
|
|
Packit |
1470ea |
</credit>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<include xmlns="http://www.w3.org/2001/XInclude" href="cc-by-sa-3-0.xml"/>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<desc>Quellcode-Versionsverwaltung mit Git</desc>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
|
|
Packit |
1470ea |
<mal:name>Mario Blättermann</mal:name>
|
|
Packit |
1470ea |
<mal:email>mario.blaettermann@gmail.com</mal:email>
|
|
Packit |
1470ea |
<mal:years>2016</mal:years>
|
|
Packit |
1470ea |
</mal:credit>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
|
|
Packit |
1470ea |
<mal:name>Christian Kirbach</mal:name>
|
|
Packit |
1470ea |
<mal:email>christian.kirbach@gmail.com</mal:email>
|
|
Packit |
1470ea |
<mal:years>2016</mal:years>
|
|
Packit |
1470ea |
</mal:credit>
|
|
Packit |
1470ea |
</info>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<title>Versionsverwaltung</title>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<synopsis>
|
|
Packit |
1470ea |
<title>Zusammenfassung</title>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
git is used for version control for all GNOME projects. This page assumes
|
|
Packit |
1470ea |
good working knowledge of git; some introductory material is available
|
|
Packit |
1470ea |
<link href="https://www.atlassian.com/git/tutorials/">here</link>, and a
|
|
Packit |
1470ea |
<link href="https://training.github.com/kit/downloads/github-git-cheat-sheet.pdf">git
|
|
Packit |
1470ea |
cheatsheet is here</link>.
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<list>
|
|
Packit |
1470ea |
<item>
|
|
Packit |
1470ea |
Make atomic, revertable commits.
|
|
Packit |
1470ea |
(<link xref="#guidelines-for-making-commits"/>)
|
|
Packit |
1470ea |
</item>
|
|
Packit |
1470ea |
<item>
|
|
Packit |
1470ea |
Include full reasoning in commit messages, plus links to relevant bug
|
|
Packit |
1470ea |
reports or specifications.
|
|
Packit |
1470ea |
(<link xref="#guidelines-for-making-commits"/>)
|
|
Packit |
1470ea |
</item>
|
|
Packit |
1470ea |
<item>
|
|
Packit |
1470ea |
Keep large changes, such as renames, in separate commits.
|
|
Packit |
1470ea |
(<link xref="#guidelines-for-making-commits"/>)
|
|
Packit |
1470ea |
</item>
|
|
Packit |
1470ea |
<item>
|
|
Packit |
1470ea |
Merge changes from feature branches by rebasing.
|
|
Packit |
1470ea |
(<link xref="#use-of-git"/>)
|
|
Packit |
1470ea |
</item>
|
|
Packit |
1470ea |
</list>
|
|
Packit |
1470ea |
</synopsis>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<section id="use-of-git">
|
|
Packit |
1470ea |
<title>Verwendung von Git</title>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
Die meisten GNOME-Repositories folgen diesen Regeln:
|
|
Packit |
1470ea |
<list>
|
|
Packit |
1470ea |
<item>
|
|
Packit |
1470ea |
No forced pushes. Except for branches with the wip/ prefix
|
|
Packit |
1470ea |
(work-in-progress), the commits’ history must not be modified, as
|
|
Packit |
1470ea |
contributors rely on it.
|
|
Packit |
1470ea |
</item>
|
|
Packit |
1470ea |
<item>
|
|
Packit |
1470ea |
Rebase commits rather than merging, to have a linear history (which is
|
|
Packit |
1470ea |
easier to follow).
|
|
Packit |
1470ea |
</item>
|
|
Packit |
1470ea |
<item>
|
|
Packit |
1470ea |
Work on feature branches on GNOME git in wip/ branches,
|
|
Packit |
1470ea |
then rebase on master and fast-forward merge the changes. It is a good
|
|
Packit |
1470ea |
practice to also add your nickname to the branch name, as
|
|
Packit |
1470ea |
wip/nickname/feature .
|
|
Packit |
1470ea |
</item>
|
|
Packit |
1470ea |
<item>
|
|
Packit |
1470ea |
Hide <link href="https://sethrobertson.github.io/GitBestPractices/#sausage">sausage
|
|
Packit |
1470ea |
making</link> by squashing commits before merging.
|
|
Packit |
1470ea |
</item>
|
|
Packit |
1470ea |
</list>
|
|
Packit |
1470ea |
</section>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<section id="guidelines-for-making-commits">
|
|
Packit |
1470ea |
<title>Richtlinien für Commits</title>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
Commits should be as small as possible, but no smaller. Each commit should
|
|
Packit |
1470ea |
address a single issue, containing only changes related to that issue. The
|
|
Packit |
1470ea |
message for each commit should describe the issue, explain what causes it,
|
|
Packit |
1470ea |
and explain how it has been fixed if it is not obvious. If the commit is
|
|
Packit |
1470ea |
associated with a bug report, the full URI for the bug report should be
|
|
Packit |
1470ea |
put on a line by itself at the bottom of the commit message. Similarly,
|
|
Packit |
1470ea |
the ID for the git commit (from <cmd>git log --oneline</cmd>) should
|
|
Packit |
1470ea |
be copied into the bug report once the commit has been pushed, so it is
|
|
Packit |
1470ea |
easy to find one from the other.
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
The changes in each commit should be easy to read. For example, they
|
|
Packit |
1470ea |
should not unnecessarily change whitespace or indentation. Large,
|
|
Packit |
1470ea |
mechanical changes, such as renaming a file or function, should be put in
|
|
Packit |
1470ea |
separate commits from modifications to code inside that file or function,
|
|
Packit |
1470ea |
so that the latter changes do not get buried and lost in the former.
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
The following principles give the reasoning for all the advice above:
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<list>
|
|
Packit |
1470ea |
<item>
|
|
Packit |
1470ea |
Each commit should take the repository from one working state to
|
|
Packit |
1470ea |
another, otherwise
|
|
Packit |
1470ea |
<link href="http://git-scm.com/book/en/v2/Git-Tools-Debugging-with-Git#Binary-Search">bisection</link>
|
|
Packit |
1470ea |
is impossible.
|
|
Packit |
1470ea |
</item>
|
|
Packit |
1470ea |
<item>
|
|
Packit |
1470ea |
Each commit should be individually revertable. If it later turns out
|
|
Packit |
1470ea |
that the commit was a bad idea,
|
|
Packit |
1470ea |
<cmd>git revert commit ID</cmd> should take the repository
|
|
Packit |
1470ea |
from a working state to another working state.
|
|
Packit |
1470ea |
</item>
|
|
Packit |
1470ea |
<item>
|
|
Packit |
1470ea |
The reasoning for each commit, and its relationship to external
|
|
Packit |
1470ea |
resources like specifications and bug reports, should be clear, to the
|
|
Packit |
1470ea |
extent that commits written by one developer a year in the past should
|
|
Packit |
1470ea |
still be understandable by a second developer without having to trace
|
|
Packit |
1470ea |
through the changes and work out what they do.
|
|
Packit |
1470ea |
</item>
|
|
Packit |
1470ea |
<item>
|
|
Packit |
1470ea |
Each commit should be written once, and designed to be read many times,
|
|
Packit |
1470ea |
by many reviewers and future programmers.
|
|
Packit |
1470ea |
</item>
|
|
Packit |
1470ea |
</list>
|
|
Packit |
1470ea |
</section>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<section id="merging-procedure">
|
|
Packit |
1470ea |
<title>Merging Procedure</title>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
To merge a feature branch named my-branch into master, use
|
|
Packit |
1470ea |
the following commands:
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
git checkout master
|
|
Packit |
1470ea |
git pull
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
git checkout wip/my-branch
|
|
Packit |
1470ea |
git rebase --interactive master
|
|
Packit |
1470ea |
# Ensure the rebase is successful; test the changes
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
git checkout master
|
|
Packit |
1470ea |
git merge wip/my-branch
|
|
Packit |
1470ea |
git push
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
# wip/my-branch can now be deleted
|
|
Packit |
1470ea |
git push origin :wip/my-branch
|
|
Packit |
1470ea |
git branch -D wip/my-branch
|
|
Packit |
1470ea |
</section>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<section id="external-links">
|
|
Packit |
1470ea |
<title>Externe Links</title>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<list>
|
|
Packit |
1470ea |
<item><link href="https://sethrobertson.github.io/GitBestPractices/">Git best practices</link> </item>
|
|
Packit |
1470ea |
<item><link href="https://help.github.com/categories/using-git/">Git FAQ</link> </item>
|
|
Packit |
1470ea |
<item><link href="https://www.atlassian.com/git/tutorials/">Atlassian git tutorial</link> </item>
|
|
Packit |
1470ea |
<item><link href="http://git-scm.com/docs/gittutorial">Offizielles Git-Tutorial</link> </item>
|
|
Packit |
1470ea |
<item><link href="https://try.github.io/">Interaktives Git-Tutorial</link> </item>
|
|
Packit |
1470ea |
<item><link href="http://www.git-tower.com/learn/">Tutorial zu git-tower</link> </item>
|
|
Packit |
1470ea |
</list>
|
|
Packit |
1470ea |
</section>
|
|
Packit |
1470ea |
</page>
|