Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Git to help writers finish their work better

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to use Git to help writers finish their work better". Friends who are interested might as well take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to use Git to help writers finish their work better".

Atom Editor

When you write in plain text, the word processor appears to be too large. It is easier to use a text editor because the text editor does not attempt to reorganize the input "effectively". It allows you to type the words in your head into the screen without being disturbed. Better yet, text editors are usually designed around the plug-in architecture, so that the application itself is basic (it is used to edit text), but you can build an environment around it to meet your needs.

The Atom editor is a good example of this design concept. This is a cross-platform text editor with built-in Git integration. If you are not familiar with plain text format and Git, then Atom is the easiest way to get started.

Install Git and Atom

First, make sure that Git is installed on your system. If you are running Linux or BSD, Git is available in the software repository or ports tree. The commands you use will vary depending on your distribution. For example, on Fedora:

$sudo dnf install git

You can also download and install Git for Mac and Windows.

You don't need to use Git directly, because Atom will act as your Git interface. The next step is to install Atom.

If you are using Linux, install Atom from the software repository through the software installer or the appropriate command, for example:

$sudo dnf install atom

Atom is not currently built on BSD. However, there are good alternatives, such as GNU Emacs. For Mac and Windows users, the installer can be found on the Atom website.

After the installation is complete, start the Atom editor.

Quick guidance

If you want to use plain text and Git, you need to adapt to your editor. The user interface of Atom may be more dynamic than you are used to. In fact, you can think of it as a Firefox or Chrome, not a word processor, because it has tabs and panels that can be opened or closed as needed, and even accessories can be installed and configured. It is impractical to try to master all the functions of Atom, but you can at least know what it has.

When you open Atom, it displays a welcome screen. If nothing happens, this screen is a good introduction to Atom's tabbed interface. You can close the Welcome screen by clicking the close icon on the top tab of the Atom window and use File > New File to create a new file.

Using plain text format is a little different from using a word processor, so here are some tricks for writing content in a way that people can understand, and Git and computers can parse, track, and transform.

Write in Markdown

Nowadays, when people talk about plain text, they mostly mean Markdown. Markdown is not so much a format as a style, which means that it aims to provide a predictable structure for text so that computers can detect natural patterns and intelligently transform text. Markdown has many definitions, but the best technical definitions and memos are on the CommonMark website.

# Chapter 1 This is a paragraph with an * italic* word and a * * bold** word in it.And it can even reference an image. ! [An image will render here.] (drawing.jpg)

As you can see from the example, Markdown doesn't read like code, but it can be thought of as code. If you follow the Markdown specification defined by CommonMark, you can reliably convert Markdown text to .docx, .epub, .html, MediaWiki, .odt, .pdf, .rtf and various other formats with one click without losing the format.

You can think of Markdown as a bit like a word processor. If you've ever written a style for a publisher to control the chapter title and its style, it's basically the same thing, except for not selecting a style from the drop-down menu, you need to add some small marks to your text. These representations are natural to any modern reader who is used to "talking with words", but when presenting the text, they are replaced by exquisite text styles. In fact, this is what the word processor does secretly in the background. The word processor displays bold text, but if you can see the generated code that makes the text bold, it is very similar to Markdown (in fact, it is a more complex XML). Using Markdown can eliminate this barrier between code and style, which on the one hand looks a little more scary, but on the other hand, you can write Markdown on almost anything that can generate text without losing any formatting information.

The popular file extension for Markdown files is .md. If you are using a platform that does not know what the .md file is, you can manually associate the extension with Atom, or just use the generic .txt extension. The file extension does not change the nature of the file. It will only change the way your computer decides what to do with it. Atom and some platforms are smart enough to know that the file is in plain text format, no matter what extension you give it.

Real-time preview

Atom has a "Markdown Preview" plug-in that shows you the plain text Markdown you are writing and how it is (usually) rendered.

Atom's preview screen

To activate this preview pane, select package > Markdown Preview > Toggle Preview or press Ctrl + Shift + M.

This view gives you the best of both worlds. You can write without the burden of styling your text, and you can see a generic sample appearance, at least in a typical digital format. The point, of course, is that you have no control over how the text is ultimately rendered, so don't try to adjust the Markdown to force a preview of the rendering in some way.

One sentence per line

Your high school writing teacher won't look at your Markdown.

It's not so natural at first, but in the digital world, it makes more sense to keep one sentence per line. Markdown ignores a single newline character (when you press Return or Enter) and creates a new paragraph only after a single blank line.

Writing in Atom

The advantage of writing one sentence per line is that your work is easier to track. That is, if you change a word at the beginning of a paragraph, if the change is limited to one line rather than one word in a long paragraph, then Atom, Git, or any application can easily highlight the change in a meaningful way. In other words, a change to a sentence will only affect that sentence, not the entire paragraph.

You might think, "many word processors can also track changes, and they can highlight individual words that have changed." But these revision trackers are tied to the word processor's interface, which means you have to open the word processor before you can browse the revision. In a plain text workflow, you can view revisions in plain text, which means that whatever you have on hand, you can edit or approve edits as long as the device can handle plain text (most of them).

Admittedly, writers don't usually consider line numbers, but it's useful for computers and is usually a good reference point. By default, Atom numbers the lines of a text document. When you press the Enter or Return key, one line is one line.

Writing in Atom

If there is a dot instead of a number in the line number of a line (in Atom), it is part of the collapse of the previous line because it is beyond your screen.

Theme

If you are a person who cares about visual image, then you may pay great attention to your writing environment. Even if you write in normal Markdown, it doesn't mean you have to use a programmer's font or write in a black window that makes you look like a programmer. The easiest way to change the look and feel of Atom is to use theme packages. Theme designers usually distinguish dark themes from light themes, so you can search with the keywords "Dark" or "Light" as needed.

To install the theme, select Edit > preferences. This opens a new tab in the Atom interface. Yes, tabs can be used to process documents and to configure and control panels. On the Settings tab, click the installation category.

In the installation panel, search for the name of the theme you want to install. Click the subject button to the right of the search field to search for only topics. When you find the theme, click its install button.

Atom's themes

To use installed themes or customize themes according to your preferences, navigate to the themes category on the Settings tab. Select the theme you want to use from the drop-down menu. Changes will be made immediately, so you can understand exactly how the theme affects your environment.

You can also change the working font in the Editor category of the Settings tab. Atom defaults to equal width fonts, which are usually preferred by programmers. But you can use any font on the system, whether it's serif, sans serif, Gothic or cursive. Whatever font you want to stare at all day.

As an illustration, by default, Atom draws a vertical line on its screen to prompt the code writer. Programmers usually don't want to write too long lines of code, so this vertical line reminds them not to write too long lines of code. However, this vertical bar makes no sense to the writer, and you can delete it by disabling the "wrap-guide" package.

To disable the wrap-guide package, select the Wrap category in the Settings tab, and then search for wrap-guide. When you find the package, click its disable button.

Dynamic structure

When creating long documents, I find it more meaningful to write one chapter per file than to write an entire book in one file. In addition, I will not name my chapter with the obvious syntax chapter-1.md or 1.example.md, but with chapter titles or keywords (such as example.md). To provide myself with future guidance on how to write this book, I maintain a file called toc.md (for "contents"), which lists the (current) order of the chapters.

I did this because no matter how much I believed that Chapter 6 could not have appeared before Chapter 1, it was almost inevitable that I would exchange a chapter or two before I finished the whole book. I have found that keeping dynamic from the beginning can help me avoid renaming confusion and rigid structures.

Using Git in Atom

What every writer has in common is two things: they write for circulation, and their writing is a journey. You can't just sit down and write and finish the final manuscript. As the name implies, you have a first draft. The draft will be revised and you will carefully keep a copy of each revision in duplicate or triplicate in case your document is damaged. In the end, you get the so-called final draft, but there's a good chance you'll return to it one day, either restoring the good part or correcting the bad part.

The most exciting feature of Atom is its powerful Git integration. Without leaving Atom, you can interact with all the main features of Git, track and update projects, roll back changes you don't like, integrate changes from collaborators, and so on. The best way to learn is to learn step by step, so this is the way to use Git in the Atom interface from beginning to end in a writing project.

First thing: display the Git panel by selecting View > Toggle Git tabs. This opens a new tab on the right side of the Atom interface. There's nothing to see right now, so just keep it open for a while.

Set up a Git project

You can think of Git as being bound to a folder. Any folder outside the Git directory doesn't know about Git, and Git doesn't know about the outside. Folders and files in the Git directory will be ignored until you grant Git permission to track them.

You can create a Git project by creating a new project folder in Atom. Select File > add Project folder, and then create a new folder on the system. The folder you created will appear in the items panel on the left side of the Atom window.

Git add Files

Right-click your new project folder and select "New File" to create a new file in the project folder. If you want to import files into a new project, right-click the folder and select "Show in File Manager" to open the folder in the system's file viewer (Dolphin on Linux or Finder on Nautilus,Mac, Explorer on Windows), and then drag and drop the file to your project folder.

After opening a project file (the empty file you created or the imported file) in Atom, click the "create Repository Create Repository" button in the Git tab. In the pop-up dialog box, click initialize Init to initialize your project directory to the local Git repository. Git adds the .git directory (which is not visible in the file manager of the system, but visible in Atom) to the project folder. Don't be fooled by this: the git directory is managed by Git, not by you, so generally you don't touch it. But seeing it in Atom is a good reminder that you are working on a project managed by Git. In other words, when you see the .git directory, you have a revision history.

Write something in your empty file. You are the writer, so just type in some words. You can enter any group of words at will, but remember the above writing skills.

Press Ctrl + S to save the file, which will be displayed in the "untemporarily changed Unstaged Changes" section of the Git tab. This means that the file exists in your project folder but has not been submitted to Git management. Allow Git to track these files by clicking the "hold all Stage All" button at the top right of the Git tab. If you have used a word processor with revision history, think of this step as allowing Git to record changes.

Git submission

Your file is now on hold. This means that Git knows that the file exists and that it has been changed since the last time Git knew about it.

Git submission commit will send your files to Git's internal and permanent archives. If you are used to a word processor, this is similar to naming a revised version. To create a submission, enter some descriptive text in the "submit Commit" message box at the bottom of the Git tab. You may feel ambiguous or write something at will, but if you want to know the reason for the revision in the future, it will be more useful to enter some useful information.

The first time you commit, you must create a branch branch. The Git branch is a bit like another space, allowing you to switch from one timeline to another to make changes that you may or may not want to retain permanently. If you eventually like the change, you can merge one lab branch into another, unifying different versions of the project. This is an advanced process that does not need to be learned first, but you still need an active branch, so you must create a branch for the first submission.

Click the "branch Branch" icon at the bottom of the Git tab to create a new branch.

Creating a branch

The first branch is usually named master, but it doesn't have to be so; you can name it firstdraft or whatever name you like, but following local customs sometimes makes it easier to talk about Git (and find answers to questions) because you will know that when someone mentions "master", they really mean "trunk" rather than "draft" or what you name the branch.

On some versions of Atom, UI may not be updated to reflect the new branches you have created. Don't worry, after making a commit, it creates a branch (and updates the UI). Press the "submit Commit" button, whether it says "create a detached submission Create detached commit" or "submit to the trunk Commit to master."

After submission, the status of the file will be permanently retained in Git's memory.

History and Git differences

A natural question is how often you should submit. There is no correct answer. Saving files with Ctrl + S and submitting to Git are two separate processes, so you will do them all the time. Whenever you feel like you've done something important or are going to try a crazy new idea that might be killed, you may want to make a submission.

To understand the impact of submission on the workflow, remove some text from the test document, and then add some text at the top and bottom. Submit it again. Do this several times until you have a short history at the bottom of the Git tag, and then click one of the submissions to view it in Atom.

Viewing differences

When you look at past submissions, you will see three elements:

The green text is the content that has been added to the document in this submission.

The red text is the content that has been removed from the document in this submission.

None of the other text has been changed.

Remote backup

One of the advantages of using Git is that it is designed to be distributed, which means that you can commit your work to a local repository and push your changes to any number of servers for backup. You can also pull changes from these servers so that any device you happen to be using always has the latest changes.

To do this, you must have an account on the Git server. There are several free hosting services, including GitHub, which developed Atom, but oddly enough, GitHub is not open source; GitLab is open source. I prefer open source to proprietary software, and in this example, I will use GitLab.

If you don't already have an GitLab account, please sign up for one and start a new project. The project name does not have to match the project folder in Atom, but if it does, it may make more sense. You can keep the project private, in which case only you and anyone you have given explicit permission can access it, or if you want the project to be available to anyone who stumbles upon it on the Internet, you can make it public.

Do not add README files to the project.

After you create the project, it will provide you with instructions on how to set up the repository. This is very useful information if you decide to use Git in a terminal or through a separate GUI, but the workflow of Atom is different.

Click the Clone Clone button at the top right of the GitLab interface. This shows the address that must be used to access the Git repository. Copy the "SSH" address instead of the "https" address.

In Atom, click the project's .git directory, and then open the config file. Add the following configuration lines to the file and adjust the seth/example.git section of the url value to match your own unique address.

[remote "origin"] url = git@gitlab.com:seth/example.git fetch = + refs/heads/*:refs/remotes/origin/* [branch "master"] remote = origin merge = refs/heads/master

At the bottom of the Git tag, a new button appears labeled "extract Fetch". Since your server is brand new, there is no data available for you to extract, so right-click the button and select "push Push". This will push your changes to your GitLab account, and now your project has been backed up to the Git server.

You can push changes to the server after each submission. It provides immediate off-site backup, and because the amount of data is usually small, it is almost as fast as local storage.

Write and Git

Git is a complex system that is useful not only for revision tracking and backup. It also supports asynchronous collaboration and encourages experimentation. This article introduces some basics, but there are more articles and whole books about Git, and how to use it to make your work more efficient, resilient, and dynamic. Starting with Git for small tasks, the more times you use it, the more questions you will ask and the more skills you will eventually learn.

At this point, I believe you have a deeper understanding of "how to use Git to help writers finish their work better". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report