About commits
Ähnlich wie beim Speichern einer Datei, die bearbeitet wurde, zeichnet ein Commit Änderungen an einer oder mehreren Dateien in Ihrem Branch auf. Git weist jedem Commit eine eindeutige ID zu, die als SHA oder Hash bezeichnet wird. Damit wird Folgendes identifiziert:
- Die jeweiligen Änderungen
- Der Zeitpunkt der Änderungen
- Wer die Änderungen vorgenommen hat
Wenn Du einen Commit durchführst, musst Du eine Commit-Mitteilung hinzufügen, in der die Änderungen kurz beschrieben werden. You can also add a co-author on any commits you collaborate on.
Wenn die Commits, die du in GitHub Desktop vornimmst, mit dem falschen Konto auf GitHub verknüpft sind, aktualisiere die E-Mail-Adresse in deiner Git-Konfiguration mithilfe von GitHub Desktop. For more information, see "Configuring Git for GitHub Desktop."
Repository administrators can enable rulesets for a branch to enforce specific conventions when committing. For example, a ruleset can require a commit to be signed, or for an issue number to be referenced at the start of a commit message. GitHub Desktop will display a warning and prevent committing if a commit does not follow the rulesets. For more information, see "Informationen zu Regelsätzen."
Choosing a branch and making changes
-
Create a new branch, or select an existing branch by clicking Current Branch on the toolbar and selecting the branch from the list.
-
Verwende deinen bevorzugten Text-Editor – z. B. Visual Studio Code –, um die erforderlichen Änderungen an Dateien in deinem Projekt vorzunehmen.
Choosing how to display diffs
You can change the way diffs are displayed in GitHub Desktop to suit your reviewing needs.
To change how you view diffs, in the top-right corner of the diff view, click .
- To change how the entire diff is displayed, under "Diff display", select Unified or Split. The Unified view shows changes linearly, while the Split view shows old content on the left side and new content on the right side.
- To hide whitespace changes so you can focus on more substantive changes, select Hide Whitespace Changes.
If you need to see more of the file than GitHub Desktop shows by default, you can expand the diff.
- To see the next few lines above or below the highlighted changes, click the arrow above or below the line numbers.
- To see the entire file, right-click in the diff view and click Expand Whole File.
Selecting changes to include in a commit
As you make changes to files in your text editor and save them locally, you will also see the changes in GitHub Desktop.
In the "Changes" tab in the left sidebar:
-
The red icon indicates removed files.
-
The yellow icon indicates modified files.
-
The green icon indicates added files.
-
To access stashed changes, click Stashed Changes.
-
Lass das Kontrollkästchen im oberen Bereich der Liste aktiviert, um einem einzigen Commit alle Änderungen in allen Dateien hinzuzufügen.
-
Um alle Änderungen an einer oder mehreren Dateien einem einzigen Commit hinzuzufügen, deaktiviere die Kontrollkästchen neben den auszuschließenden Dateien, sodass nur die Dateien übrig bleiben, die im Commit enthalten sein sollen. Nach dem Auswählen einer Datei kannst du das Kontrollkästchen mit den Tasten
Spacebar
oderEnter
umschalten.
Creating a partial commit
If one file contains multiple changes, but you only want some of those changes to be included in a commit, you can create a partial commit. The rest of your changes will remain intact, so that you can make additional modifications and commits. This allows you to make separate, meaningful commits, such as keeping line break changes in a commit separate from code or prose changes.
To exclude changed lines from your commit, click one or more changed lines so the blue disappears. The lines that are still highlighted in blue will be included in the commit.
Discarding changes
If you have uncommitted changes that you don't want to keep, you can discard the changes. This will remove the changes from the files on your computer. You can discard all uncommitted changes in one or more files, or you can discard specific lines you added.
Discarded changes are saved in a dated file in the Trash. You can recover discarded changes until the Trash is emptied.
Discarding changes in one or more files
-
Wähle in der Liste der geänderten Dateien die Dateien aus, in denen du die Änderungen seit dem letzten Commit verwerfen möchtest. Um mehrere Dateien auszuwählen, drücke die
shift
-Taste, und klicke auf den Bereich der Dateien, deren Änderungen du verwerfen möchtest. -
Klicke auf Änderungen verwerfen oder Ausgewählte Änderungen verwerfen, um Änderungen in einer oder mehreren Dateien zu verwerfen, oder klicke auf Alle Änderungen verwerfen, um die seit dem letzten Commit an allen Dateien vorgenommenen Änderungen zu verwerfen.
-
Um die Änderungen zu bestätigen, überprüfe im Fenster „Verwerfen von Änderungen bestätigen“ die betroffenen Dateien, und klicke auf Änderungen verwerfen.
Discarding changes in one or more lines
You can discard one or more changed lines that are uncommitted.
Note: Discarding single lines is disabled in a group of changes that adds and removes lines.
To discard one added line, in the list of changed lines, right-click the line number of the line you want to discard, then select Discard Added Line.
To discard a group of changed lines, right-click the vertical bar to the right of the line numbers for the lines you want to discard, then select Discard added lines.
Write a commit message and push your changes
Once you're satisfied with the changes you've chosen to include in your commit, write your commit message and push your changes. If you've collaborated on a commit, you can also attribute a commit to more than one author.
Note: Standardmäßig überträgt GitHub Desktop den von Dir erstellten Tag in Dein Repository mit dem zugehörigen Commit. For more information, see "Managing tags in GitHub Desktop."
-
Gib im unteren Bereich der Liste der Änderungen im Feld „Summary“ (Übersicht) eine kurze, aussagekräftige Commit-Mitteilung ein. Optional kannst Du im Feld „Description“ (Beschreibung) weitere Informationen zur Änderung hinzufügen.
-
Optionally, to attribute a commit to another author, click the add co-authors icon and type the username(s) you want to include.
-
Klicke unter dem Feld „Beschreibung“ auf An BRANCH committen.
-
If the branch you're trying to commit to is protected, Desktop will warn you.
- To move your changes, click switch branches.
- To commit your changes to the protected branch, click Commit to BRANCH.
For more information about protected branches, see "Informationen zu geschützten Branches."
-
Um deine lokalen Änderungen per Push in das Remoterepository zu übertragen, klicke auf der Repositoryleiste auf Ursprung pushen.
-
If you have a pull request based off the branch you are working on, GitHub Desktop will display the status of the checks that have run for the pull request next to the "Current Branch" section of the repository bar. For more information about checks, see "Viewing and re-running checks in GitHub Desktop."
If a pull request has not been created for the current branch, GitHub Desktop will give you the option to preview the changes and create one. For more information, see "Creating an issue or pull request from GitHub Desktop."