Tag: ファイル管理

  • Git: The Ultimate Tool for File Version Control — A Beginner’s Guide

    Git: The Ultimate Tool for File Version Control — A Beginner’s Guide

    What is Git?

    Many of you probably knew about GitHub before you ever heard of Git.
    When looking for a program or piece of software to reference, GitHub pages often come up in search results, and I suspect plenty of people have simply downloaded something from there without really understanding how it works.

    GitHub is indeed a place where programs are shared, but it is more than just a sharing platform—it is a tool for using something called Git online.

    Git is a tool for version control of files.
    By recording the changes you make to your files, it lets you return to any recorded version at any time.

    When you have someone review a presentation manuscript, you probably save the file before review, the reviewed file, and the file you revised based on the comments as separate files.
    With Git, you can handle all of those changes easily, within a single file.

    You can find Git here

    The three places in Git

    A record made with Git—and the act of making that record—is called a “commit”.

    The place where commits accumulate is called a “repository”.
    In other words, a repository is where the change history is kept.
    A repository on your own computer is called a “local repository”, while one hosted remotely, such as on GitHub, is called a “remote repository”.

    To manage files with Git, you designate a folder to be managed by Git.
    Within that folder there are three places:
    the working tree, the staging area, and the Git directory.

    The working tree is where your files live, and simply editing a file here does not yet save the change history as a commit.

    The staging area is where you register the files to be committed.
    Files on the stage likewise have not had their change history saved yet; think of it as the place where you declare, “I am going to commit this file.”

    The Git directory is where commits are stored.
    Files committed here are stored as files that will not be altered.
    In principle, the content recorded by a commit cannot be changed or deleted afterward.
    Once committed to the Git directory, a change is officially recorded in the history.

    Basic usage of Git

    I will leave the detailed usage for you to look up, but here I will give a rough overview of the actual operations.

    Git is generally operated through Git Bash on Windows (installed together with Git) and through the terminal on macOS and Linux. (I will refer to both simply as the terminal here.)

    There are GUI tools that may feel more familiar, but once you get used to it, using Git from the CUI is extremely convenient, so I recommend starting with the CUI from the outset.
    You should get the hang of it within an hour.

    First, to start managing files with Git, create a local repository.
    Begin by moving to the directory you want to manage with Git in the terminal.
    Then,

    git init

    Entering this sets you up for version control with Git.

    Next, to record changes in the staging area,

    git add ファイルパスもしくはディレクトリパス

    Running this registers the specified file in the working tree to the staging area.

    Next,

    git commit

    This commits the files in the working tree.

    To check which files are currently in which state, run

    git status

    Run this command.
    The commit history can be checked by

    git log

    running this command.

    Basically, the workflow is to run git add, then git commit to create a change record, and use git status to check the current state whenever you run into trouble.

    Below is a reference.
    It is a book that is very easy to follow even for beginners, and I referred to it while writing this article.
    If you would like to study this in more depth, I recommend it.