Get straight to the point

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

Git is a version control system. It is a version control system. As for the other version of SVN, there is no need to go through a lot of differences on the network, just need to know one thing, Git is distributed, SVN is not, other disadvantages you will gradually realize when you use it more.

Git is a multi-user synchronization tool. For a file, multiple people can modify it at different times and places, and then perform a series of operations to synchronize the changes.

The foundation

How do you install it first

windows

Git-scm.com/download/wi… After downloading, next great method. Again, it is not recommended to install the software on disk C except under special circumstances.

mac

As for the MAC, no, no, no, there will be no mba or MBP in 2202 that does not have Homebrew speaker 🐶🐶🐶 installed.

But the website does recommend it

Whatever the platform, open a terminal and type git version. If you see the following, the installation is successful.

Let’s talk about the basics of Git

Local refers to the local PC, Origin refers to the remote repository, and remote refers to the remote repository of someone else. Remote is often referred to as a remote repository, where files are modified together. And I’ll talk about some of the operations that go into it.

The cabin

Start by creating a remote repository of your own on Gitee

Note that the selection is open source, private is only your own access, after the creation of gitee can be seen. The next step is to clone or pull the remote repository locally, using the command line first.

  1. clone

    Git clone (SSH, HTTPS)

    The.git directory tells you that the directory is in a git repository

    There will be a fatal: not a Git repository (or any of the parent directories):.git

  2. add

    Add file firstly git add

    For ADD

    • add fileIs to add a file
    • add file1 file2It’s multiple files
    • add .Is all the modified files in this directory.

    One of the nice things about Git is that it will remind you of the correct approach when you make a typo, or what went wrong. Then use git status to check the status. This command is more commonly used on the command line, so I won’t mention it separately here.

    Git rm –cached

    When you withdraw your submission, use status again to find that your files have become untraced and are not traced by Git

  3. commit

    A commit is a commit to a local repository. Although you created a new file in the repository, you did not commit it to Git

    Note that this is a local repository, not a remote repository

    Git commit -m ‘message’ git commit -m ‘message’

  4. push

    If you want to commit to a local repository, you have to do a push operation

    It can be found that Permission Denied has no Permission. This is because Gitee does not know us, so we need to generate an SSH public key and upload it to Gitee.

    To generate a public key

    First, look for the id_rsa and id_rsa.pub files in your.ssh folder (which is generated by default on both Windows and Macs, in the user’s directory).

    Once you have the generated public key, go to the Gitee Settings and let Gitee know about the public key

    Now let’s try pushing

    If you look at gitee, there are already two files in the code cloud, followed by the message written at commit time.

  5. remote

    Generally speaking, push is followed by the address, but if there is only one remote address in the local, it is not followed by the address. You can set the remote warehouse address by using the following command.

    Of course, when we push to someone else’s remote warehouse, we definitely do not have permission, because we do not know, so we need fork and Mr Later.

  6. fork

    A fork is a remote copy of someone else’s repository code into your own repository code, which is then fork locally

    Clone the IP address to the local PC

  7. merge reques

    Now it is on our own computer, our own code cloud account, so we can push. However, at work, there must be a server to store the code, and it is impossible to store so many people’s public keys on the server, and if everyone can push up so easily, there will be more conflicts, which is not good for management.

    First create a Java file and add Commit push, where the push can only be pushed to its own remote repository, and the organization’s remote repository does not exist.

    In order for the remote repository to also have the files we modify or add, we need to issue the Merge Request. It is called Merge Reques on GitLab and pull Reques on GitHub or Gitee. As for the difference, it doesn’t make any difference to me.

    First, take a look at the local pull request

    After adding the corresponding information, it can be submitted to Mr, and then it needs to be reviewed by the person in the remote warehouse. Generally speaking, the company will have the specified person to review the code to see whether there are any mistakes, whether it is good or not, and generally whether it can be incorporated.

    Take a look at the pull request for the remote repository

    You can see that the remote has successfully merged the code through a series of operations, and the remote repository also has the modified code, and will receive a successful merge message on its own Gitee.