قالب وردپرس درنا توس
Home / Tips and Tricks / How authors can use GitHub to save their work

How authors can use GitHub to save their work



  The GitHub logo.

There are many ways you can manage and save your writing projects. Some prefer cloud storage services (like Dropbox) or online editors (like Google Docs), while others use desktop applications (like Microsoft Word). I use GitHub.

GitHub: It's more than just code.

I'm using Git and GitHub to store and access all my lyrics. Git is an effective tool that lets you track document changes and upload them to GitHub at great speed. You can also quickly and easily download your work to a second or third device.

If you've never heard of GitHub, it's the world's most popular destination for storing and managing open source code. That may sound like a crazy place to host your lyrics, but it is not! Finally, code consists only of individual lines of text, eg. From your article, story or dissertation.

Around 201

3, GitHub started encouraging users to create repositories for all kinds of information, not just code. GitHub has never really left its encoding roots, but some people still use it to store texts and other non-coding projects. For example, one person used Git and GitHub to write a textbook while another person wrote a novel. Browse Google and find all sorts of crazy uses for GitHub.

What are Git and GitHub?

<img class = "wp-image-438272 size-full" data-pagespeed-lazy-src = "https://www.howtogeek.com/wp-content/uploads/2019/08/GitHubRepo-1. png.pagespeed.ce.ofilkBRNGY.png "alt =" The Tabbed Interface of a GitHub Repository An open source program by Linus Torvalds, known on Linux, that tracks document changes and makes it easy for multiple people to work remotely on a document In technical terms, it is referred to as a distributed version control system (or distributed VCS) Git does not randomly store versions of your documents at set intervals, instead changes to your documents are saved only when prompted.

Your documents form Repository (or repo), which is just a fancy term for your project folder, for example, the Documents folder in Windows would be a repository if you managed it with Git (but you do not).

If you make changes save to your documents in git, this is called "commit". A commit is just a record of recent changes made to a document. Each commit is assigned a long string of numbers and letters as an ID.

When you call an earlier commit by its ID, the entire project does not appear as it would in Word's document history. You only see the most recent changes when this commit was made. However, this does not mean that not the entire project has been recorded. You can delete all your texts from a project folder and still get the latest version with a few git commands. You can even go back and see what the project looked like a week ago or half a year ago.

You can also add messages to any commit, which is very useful. For example, if you write something but are not sure you want to keep it, just commit. The section then remains in your commit history, even if you later delete it from the project.

Git works best on the command line, which is a big plus but also has drawbacks. Use the command line to create commits and upload changes. However, if you want to see a commit history, this is not ideal.

That's why many people like GitHub – a popular online service that provides a web interface for your git repositories. GitHub makes it easy to view past commits and download your texts to multiple PCs.

With Git and GitHub I can control my version history on a granular level. And I can write my lyrics on any PC running a bash command line that nowadays includes Windows, Mac, Linux, and Chrome OS computers.

Simple text files make work easier

  The great text editor.
Git can help you save your lyrics, but does not make you a better writer.

Git and GitHub write pretty much all file types, though it works best with plain text. If you write in Microsoft Word, it works, but you can not see your recent commits on the command line or in GitHub. Instead, you'll need to go to the command line to get a "past commit" ("checkout") and then open your Word file. The Word file looks the same as the original commit, and you can return to your current version with another quick command.

Using Scrivener also works. Scrivener saves files as text, indicating past commits on GitHub and on the command line. However, Scrivener also stores data that is important to the program, but not for you. There is a lot of garbage in every commit that makes reading difficult.

I use plain text files, as this is all you need to string words together, especially in your first drafts.

Steps with Git

Let's get to the technical details of how this all works. We start with the PC and then get into the cloud with GitHub.

To get started, you need the terminal program on macOS or Linux. If your computer is running Windows 10, you will need to install Ubuntu or another Linux distribution through the Windows Subsystem for Linux (WSL), which is pretty straightforward. In our tutorial, you will learn how to install the Linux bash shell on Windows 10. If you're using an older version of Windows, you can use Cygwin to get a bash shell.

Open your terminal and navigate to the folder you want to use as a git repository. Suppose for our purposes, we have a folder named "MyNovel" in the folder "Documents". Note that there is no space between the words of our git repos. It will make your life easier if you do so in this way, because Bash does not like and becomes confusing with spaces.

Next, navigate to the MyNovel folder in the terminal. In Windows 10, the command is:

  cd / mnt / c / Users / [YourUserName] / Documents / MyNovel 

Any WSL command that interacts with files stored in Windows must use / mnt / . Also note that the lower case letter "c" indicates the drive you are on. If your files are on a D: / drive, use / d / .

The command is much simpler for MacOS and Linux:

  cd ~ / Documents / MyNovel [19659030] From here the commands are the same. 

Now we need to initialize the MyNovel folder as a git repository. This command works regardless of whether you are starting a new novel or have already stored files in it.

  git init 

Your folder is now a git repository. Do not you believe me? Type:

  ls -a 

This command prompts the computer to list all items in the current folder, including hidden items. Above should be something called ".git" listed (note point). The hidden ".git" folder stores the version history of your document. You should never have to open it, but it has to be there.

The First Commit

Before we make our first commit, Git wants to know your name and email address. Git uses this information to identify who made the commit. This information is contained in the commit log. For practical reasons, this does not matter because authors usually fly alone, but Git still needs it.

To set your e-mail address and address, do the following:

  git config --global user.email "[Your email]"

git config --global user.name "[Your name]" 

Done. Now for the first commit.

Suppose the MyNovel folder contains three documents named Chapter1, Chapter2, and Chapter3. To save changes, you must tell Git to track these files. Enter the following:

  git add. 

This point tells Git to monitor all untracked files in the folder (that is, files for which you want to create a history). This command also instructs Git to prepare all currently tracked files that have been modified. This process is known as commit staging files.

Staging is not so important to our purposes, but it can be useful. If you make changes to Chapter 2 and Chapter 3, but only commit the changes in Chapter 2, you would prepare Chapter 2 as follows:

  git add Chapter2.doc 

This tells Git that you want to get the changes in Chapter 2 ready to commit, but not in Chapter 3.

Now it's time for the first committal:

  Git Commitment -m "This is my first commemorative." 

The -m is called a flag, and it tells git you want to commit and pin a message that you see between the quotation marks. I like to use my commit messages to mark the number of words. I also use them to record special information, such as: B.: "This commit contains an interview with the CEO of Acme Widgets."

When I write a story, I can insert the following message: "This commit contains the new scene in which the dog runs away. "Helpful messages make it easier to find commits later.

Now that we've started tracking our documents, it's time to put our writing in the cloud with GitHub. I use GitHub as an extra backup, as a reliable place to view my document changes and to access my data on multiple PCs.

Getting Started with GitHub

<img class = "wp-image-438279 size-full" data-pagespeed-lazy-src = "https://www.howtogeek.com/wp-content/uploads/2019 /08/RepoNew.png.pagespeed.ce.m8BOJue6HD.png "alt =" The text form to create a new GitHub repository. [19659057] You complete the form to create a new GitHub repository.

First You need to sign up for a free account at GitHub (you do not need a paid account to create private repositories), but you can only work with up to three people on a private repo if you have a team of five or more people, If you're working on an item, you'll need to sign up for a pro account ($ 7 a month at this time).

After you've created your account, we'll create a new repo. Sign in to your account and go To https://github.com/new.[19659005<DaserstewaswirtyoumustrenametherepositorySiekIfyouhaveusedthesameusernameforyourPCenter"MyNovel"under"RepositoryName"

The "Description" is optional, but I like to use it. You can type: "My Fabulous New Novel about a Boy, a Girl, and Their Dog," and so on.

Next, check the "Private" radio button, but do not select the "Initialize this repository" check box with a README. "We do not want that because we already have a repository on our PC. If we are creating a README file, it will be more difficult.

Then click Create Repository. Copy the URL under "Quick Setup - if you have already done so". It should look something like this:

  https://github.com/ [Your GitHub User Name] / MyNovel.git 

Now it's back on the desktop and on our popular command line.

Move your desktop repository to the cloud

  A PC command line.
Using git on the command line.

When connecting a repo to GitHub for the first time, you must use some special commands. The first is:

  git remote add origin https://github.com/[19459042</MyNovelgit[19659030<DiesteiltGitmitdasseinRemote-RepositoryderUrsprungvon"MyNovel"istDieURLverweistdannaufGitdieserentfernteUrsprungLassenSiesichnichtzusehraufdenBegriff"Herkunft"eineristnureineKonventionSiekönnenes"flauschig"nennenwennSiemöchten-OriginistnureinfacherdaesdiegebräuchlichsteMethodezurVerwendungvonGitist

Wenn new Uploading changes with Git is called a push. When you download changes, it's called "pull" or "fetch." Now it's time to send your first commit to GitHub. Do the following:

  git push -u origin master 

You will be asked to enter your GitHub username and password. If you enter your credentials correctly, everything is uploaded and you're ready to go.

If you want more security for your GitHub uploads, you can use an SSH key. This allows you to use a single password for the SSH upload key, so you do not have to enter your full GitHub credentials each time. Also, only someone with the SSH key can upload file changes.

For more information about SSH keys, see GitHub for complete instructions on how to use them. You can also save your Git credentials on your PC.

Done! If you want to make changes to your files now, you can do so with these three short commands (after navigating to the MyNovel folder):

  git add. 

Translated: "Hey, Git stage for Transfer all untracked files as well as new changes to files you are already tracking.

  git commit -m "1,000 words in the new iPhone review." 

message. "

  git push origin master 

Translation:" Hey Git, upload the changes to the original version of this project to GitHub from my master copy on this PC.

Git and GitHub Bonus Tips

That's about it all, but here are some additional tips to further enhance your experience with Git and GitHub:

Show previous commits

  One GitHub repository interface with commit history.
GitHub allows you to see past commits.

To see previous commits, go to your MyNovel repository on GitHub. At the top of the main page, under the "Code < >" tab, you will see the section "[X] Commits".

Click on it and you will see a list of all your commits. Click on the desired commit and you will see your text (if you typed it in plain text and not in Word). All that is highlighted in green was new text when the commit was created. Everything in red was deleted.

Use the pull command.

It's easy to get a new repository on another computer. Simply navigate to the location where you want to save the repo to the new computer, such as B. cd ~ / Documents . Then type in:

  git pull https://github.com/[19459042</MyNovelgit[19659030<SendyourcredentialswhentheyarerequestedandinlessthanafewsecondsyoucanmakeachangeoverandreturnthemtoGitHubvia git push origin master . If you return to the PC you normally work on, just open the command line, navigate to your project folder, and enter  git pull.  The new changes will be downloaded and your writing project will be up-to-date on all devices. 

Do not cross streams

Writing is in most cases not teamwork and requires only one person. For this reason, Git is used in this article in a way that would not be suitable for a multi-person project. In particular, we made changes directly to the master version of our novel instead of creating so-called "branches." A branch is a practice version of the novel in which you can make changes without affecting the original master. It's as if two different copies of your novel exist in parallel, without any impact on the other. If you like the changes in the practice branch, you can merge them into the master version (or master branch). If you do not want that, that's okay too. Just throw away the exercise branch.

Branches are very powerful, and their use would be the primary workflow for multiple authors in a single project. Solo authors, in my opinion, do not need to use branches - unless you make different changes to the master branch on multiple PCs at the same time.

For example, you should do your work on your complete desktop, complete your commits, and then transfer the changes to GitHub. Then go to your laptop and drag down any new changes before you make any further changes. If you do not, Git may call "conflicts". In that case, Git says, "Hey, there are changes in GitHub and on this PC that do not match. Help me figure that out."

It can be difficult to find the way out of a conflict so, whenever possible.

Once you've started using git, you can learn a lot of things, such as branching, the difference between getting and pulling, what GitHub's retrieval requirements are, and how to deal with the dreaded conflict. 19659005] Git may seem complicated to newbies, but once you get the hang of it, it's a powerful tool that lets you manage and save your text.


Source link