“This is my fourth day of participating in the First Challenge 2022. For more details: First Challenge 2022.”

The vast sea of millions, thank you for this second you see here. I hope my article is helpful to you!

May you keep your love and go to the mountains and seas in the coming days!

We should have downloaded the Git tool yesterday, if you can’t go back to the previous article (Git download) to download, today we officially step into the process of learning and using Git! First today we will learn how to use the version library and how to add files to the version library!!

😋 Git use

🍈 Create a version library

After initial configuration, how can we use Git to manage the code, but how? So first we need to create a version library. 👇 👇 👇

What is a repository? ❔ repository is also called repository. Git can keep track of every change or deletion of a file, so that it can be traced at any time in history or “restored” at some point in the future.

Git init = git init = git init = git init = git init = git init

Git repository: Git repository: Git repository: Git repository: Git repository: Git repository: Git Repository: Git Repository

Note: Do not manually modify the files in this directory, otherwise you will break your Git repository and you will not be able to use it. If you don’t see the.git directory, that’s because it’s hidden by default. You can just watch me do it like this

🍉 How do I add files to the repository

Now that we have the repository created, how do we add file files to the repository? Why do YOU need to put it in a repository?

Now, if we create files, we just operate outside git repository, so we can’t enjoy the use of Git, so we need to add files to Git repository. So how do you add it?

Do not know each guest officer has seen Zhao Benshan and Song Dandan’s sketch, there is a bridge section, Song Dandan asked Zhao Benshan: the elephant into the refrigerator need a few steps? Now, what steps does it take to add a file to a local repository?

For now, it takes three steps to put an elephant in the fridge and two steps to put a file in a Git repository. More convenient and fast 😎!

First, we need to create a file (hello.txt) and add the words: helloGit!

The next few steps are to put the code and screenshots in, you can copy and paste into the local test! Each step is followed by a comment. Look how sweet I am. You don’t see many guys as sweet as me. O (studying studying) O ha ha ~ 😚 😚 😚

$vim hello.txt (create vim editor, edit hello.txt file)Copy the code

helloGit! In vim editor, type I insert, write helloGit! Use the Esc key in the upper left corner and type :wq to exit the vim editor.Copy the code

We can see that the hello. TXT file is added to the folder.

First, tell Git to add the file to the repository with the git add command:

$git add hello.txt $git add hello.txtCopy the code

Execute the above command, nothing is displayed, that’s right, the Unix philosophy is “no news is good news”, indicating success.

Git commit:

[master (root-commit) c672725] add hello. TXT to 1 file changed, 1 insertion(+) create mode 100644 hello.txtCopy the code

Git commit -m: git commit -m: git commit -m: git commit -m: git commit

-m “XXX”? There are ways to do this, but it is strongly discouraged because the input submission instructions are important for yourself and for others to read 🤛. If you really don’t want to enter the instructions, please Google, I really don’t want to tell you this parameter, I don’t want to harm you. Remember, this submission note has to be written and meaningful.

Git commit: 1 file changed: 1 file changed (our new hello. TXT file) 1 Insertion (+) : Inserted two lines (Hello. TXT has one line)

So why does Git need to add and commit files? Since you can commit many files at once, you can add different files multiple times, such as:

$ git add file1.txt
$ git add file2.txt file3.txt
$ git commit -m "add 3 files."
Copy the code

🌸 summary

I believe that you see here, today’s git tutorial should be simple for you! What we are going to do today is to create a version library, and can add files to the version library, so that the subsequent can smoothly manage files!!

Let’s refuel together, too! I am not just, if there is any missing, wrong place, also welcome you to criticize in the comments of talent leaders! Of course, if this article is sure to help you a little bit, please kindly and lovely talent leaders give a thumblike 👍, save it, and welcome to follow ❤️❤️❤️ [favorite food of canned fish] 👍, thank you very much! If you like canned fish too! 💕 💕 💕

Here, the world is closed for today, good night! Although this article is over, I am still here, never finished. I will try to keep writing articles. The coming days are long, why fear the car yao ma slow!

Thank you all for seeing this! May you live up to your youth and have no regrets!