Howto/pages/04.Contribute/01.howto/01.git/1.intro/docs.en.md

3.7 KiB
Executable File

title published visible updated taxonomy page-toc
Preparing the workspace: Git basics true true
last_modified app app_version
October 2021 Git 2.33.0
category tags
docs
contribute
git
active
true

Git basics

The aim of the following tutorials is to introduce you to the basics of Git, the main tool we use to manage the Howto project files. Therefore, we will not cover all the aspects of its usage, only some basic concepts and commands.
If you get more interested about Git, there are lots of in-depth tutorials and documentation written about it that you can easily find on the internet.

What does Git do?

When you read a Disroot tutorial, what you are seeing is the representation in your browser of a piece of code, in our case, a text file written in a formatting syntax called Markdown. The entire code of this site and its content is hosted in a git repository, a folder containing all the project files and the changes history of each and every one of those files (what has changed, who has changed it and why it has changed).

In this repository (or repo) there is a main branch (or "master branch"), the default project folder where is the "final" code, the one is online.

When a tutorial needs to be modified (e.g., some software has been updated, typos were found in a document, there is information to be added/removed, etc) what we do is copy the remote repository into our machine, this way we can work locally on the files. This procedure is called cloning and once it is done, all Git operations are managed from our local repository.

Next step is to create a new branch, a fork of the main branch on which we can make modifications without compromising the original code.

Setting your username and email

In order to be able to send your work from your machine to the remote repository, it is necessary to setup your Gitea username and email.

  1. Open a terminal and start Git
    git init

  2. Type and complete with your information the following commands:
    git config --global user.email user@email
    git config --global user.name "User Name"

Cloning the Howto Disroot repository

Git is designed with collaboration in it's core. So, first thing we need to do is get a copy of all files within the project onto our local hard drive. This process is called "cloning a repository". All modifications are done on our local machine (most of the work is made offline). Once we've decided that the changes (new tutorial, translation) are finished we can sent/sync them back to the repository on the server (push).

To clone the repository just open a terminal, navigate to the directory you would like to clone the repository to, and run git clone <url> command, where is basically the address of the repository you want to clone. In our case it would be:

git clone https://git.disroot.org/disroot/howto

Once the repository is copied to your hard drive you will see a howto directory that consists of all the files you could previously browse in your web browser when on our repository's url.

You can later move that directory to any place you want on your computer.

Access to the repository

In order to be able to commit changes to Disroot's git repository, you need to request access. This is done via our git project page

Once admins grant you the access, you can "push" your changes to the server.

!! !! NOTE: You can start working without access granted as all the changes happen on your local computer.