![]() |
Recording changes | ![]() |
In Git, a commit records the state of some files, together with a message which describes the changes, your name and the date. This page describes the full mode; in the simple mode, you rather save snapshots, which are commits of all files.
Version\(\rightarrow\)Commit (or ⌘⌃#C) opens a dialog with:
a box for the commit message: a short summary on the first line, followed by more details if needed;
the list of the changed files, where you select those which should be part of the commit (the buttons All and None select all files or none);
Suggest message, which describes the selected changes: for each TeXmacs document, it lists the sections which contain changes, for instance “Update paper.tm: Introduction, Proofs”;
Amend last commit, for correcting the last commit instead of making a new one, for instance when you forgot a file (with an empty message, the previous message is kept);
Initially, the files whose changes were staged are selected (see below). If nothing was staged, then all changed files which are already under version control are selected; new files have to be selected explicitly. When the corresponding preference is set (it is by default), the message is also suggested from the start. Documents with unsaved changes are saved before the commit, since Git only records what is on disk. If the commit cannot be done, for instance because the message is empty, then the dialog stays open and explains why.
During a merge (see resolving conflicts), the dialog proposes the message prepared by Git and keeps all files selected, since a merge commit must contain all changes. It refuses to commit as long as some conflicts remain.
A quicker way of committing is to type a message in the box of the Git panel and to click on Commit: the staged changes are committed or, if nothing was staged, the changes of all files under version control.
The submenu Version\(\rightarrow\)This file contains the operations which apply to the current document. Only the entries which make sense in its current state are shown:
Put a new file under version control. It will be part of the next commit.
Mark the current changes of the file as part of the next commit.
Undo the previous operation. The file itself is not modified.
Save the document and commit it on its own, after asking for a message.
Put back the version of the file which was last staged or committed, after a confirmation. The changes since then are lost, unless you saved them elsewhere.
Staging allows you to prepare a commit in several steps, and to commit some of your changes while keeping others for later. The staged version of a file is the version which will be recorded by the next commit. Besides Version\(\rightarrow\)This file\(\rightarrow\)Stage changes, you can stage files from the Changes tab of the Git panel, from the status page (Version\(\rightarrow\)Git\(\rightarrow\)Status), or all at once with Version\(\rightarrow\)Git\(\rightarrow\)Stage all changes. When a file is selected in the commit dialog without having been staged, all its changes are committed; when it was staged, it is committed exactly as it was staged.
If you do not want to deal with staging, then just select the files in the commit dialog.
A document is often made of several files: included documents, images, bibliographies, style files. For TeXmacs documents, Version\(\rightarrow\)Project\(\rightarrow\)Commit project opens the commit dialog with all changed files of the project selected. If some of these files are not yet under version control, then Version\(\rightarrow\)Project also offers to add them; forgetting them is a common reason why a coauthor cannot typeset a document.
Version\(\rightarrow\)Git\(\rightarrow\)Status (or ⌘⌃#S) opens a page with the current branch, how many commits are waiting to be sent or received, and the lists of conflicts, staged changes, other changes and untracked files. Each file comes with buttons for comparing, staging, unstaging, discarding or adding it. The buttons at the top give access to the commit dialog, to the other pages (Log, Graph, Branches, Output) and to the exchanges with the server. The page is updated when you save a document; use Refresh after changing files outside TeXmacs.
If you use GnuPG, then your commits and tags can be signed, using Version\(\rightarrow\)Git\(\rightarrow\)Preferences\(\rightarrow\)Sign commits and tags or the preferences dialog. The page of a commit shows whether its signature is valid.