![]() |
Getting started with Git | ![]() |
The Git program must be installed on your computer; TeXmacs uses it for all operations. If it is not found, you may indicate where it is in Version\(\rightarrow\)Git preferences. Git also needs to know your name and e-mail address, which are recorded in each commit. If you never configured them, then type once in a terminal
git config --global user.name "Your Name" git config --global user.email "you@example.org" |
For exchanging changes with a server, Git must be able to connect without asking for a password in a terminal: use an SSH key with an SSH agent, or a credential helper (see the documentation of your hosting service).
By default, the Version menu is shown for all documents which belong to a Git or Subversion working tree. You may show it for all documents, or never, using Tools\(\rightarrow\)Versioning tool.
If the current document does not belong to a repository yet, then Tools\(\rightarrow\)Versioning tool\(\rightarrow\)Create Git repository creates a new repository in the directory of the document (the same entry is in the Version menu, when it is shown). All files in this directory and its subdirectories may then be put under version control. A file .gitignore is created as well, which tells Git to ignore the backup files of TeXmacs.
If your coauthors already have a repository on a server, then use Tools\(\rightarrow\)Versioning tool\(\rightarrow\)Clone Git repository (or Version\(\rightarrow\)Clone Git repository). In the dialog, enter the address of the repository, as given by the hosting service, and the directory in which the copy should be made. The copy is made in the background, after which the status of the new working tree is shown. The repositories you worked with recently are listed in Version\(\rightarrow\)Recent Git repositories.
The configuration of a repository may instruct Git to run arbitrary programs, even when TeXmacs only asks for the status of a file. For this reason, TeXmacs only runs Git in the repositories which you created or cloned with TeXmacs, and in those which you explicitly trust. When you open a document inside another repository, for instance one which you cloned in a terminal, the Version menu only contains Version\(\rightarrow\)Use Git in this folder, besides the tools for comparing files. Choose it if you know where the repository comes from; the complete menu then becomes available. Only do this for folders whose origin you trust, such as your own projects: do not do it for an archive you received by e-mail.
The first time you open the Git panel, TeXmacs asks you how you want to work:
Save snapshots and synchronize with coauthors. The details of Git remain hidden. See the simple mode.
Staging, branches and remotes, for users who know Git.
Until you choose, the full mode is used. You may change your choice at any time in Version\(\rightarrow\)Git preferences.
For a document in a repository, the Version menu is organized as follows:
At the top, if the document has a conflict: Resolve conflict and Mark as resolved (see resolving conflicts).
The most frequent actions: Commit (or Save snapshot in the simple mode), Synchronize (when the repository has a remote, see working with coauthors) and Git panel.
The actions on the history of the current document: Compare with, Restore version, History of this document and Who changed what.
The submenus This file (full mode only) and Project (for TeXmacs documents), and a submenu for the whole repository, whose name summarizes its state, like Git (main, 3 changed, 1 ahead). In this manual, we will call it Version\(\rightarrow\)Git.
The submenu Differences, for going through the differences between two versions, and Git preferences.
The footer at the bottom of the window also shows the state of the repository, for instance
Git main · 2 changes · ↑1 |
This means that you are on the branch main, that two files were changed or added since the last commit, and that one commit is waiting to be sent to the server. Similarly, ↓2 means that two commits of your coauthors are waiting to be received. The footer shows saved when there are no changes, the number of conflicts during a merge, and working… while Git is running in the background.
Version\(\rightarrow\)Git panel opens a panel on the right of the window, which shows the state of the repository of the current document and stays up to date while you work. At the top, you find the current branch, the number of commits ahead and behind, and buttons for getting and sending changes (or for synchronizing, in the simple mode). The panel has three tabs:
The changed files, grouped into conflicts, staged changes, other changes and new files (in the simple mode, only conflicts and changes), with buttons for staging, comparing and resolving them. Below, a box for a message, with Suggest, which describes the changes, and Commit (or Save snapshot). Each repository keeps its own message.
The recent versions of the current document, each of which can be compared with the current one or restored.
The branches of the repository, with buttons for switching to another branch or creating a new one.