Git local Repository (Repository) Details
Outline:
I. Preface
Ii. Overview
3. Install Git on Windows
4. Create a local repository
5. Detailed explanation of local Warehouse Management
Vi. Summary
Note: CentOS 5.5 x86_64, Git server version: git version 1.8.2.1, and Client version: git version 1.9.2.msysgit.0. Download all the software here: http://msysgit.github.io /.
I. Preface
Actually, it is. I thought Git had just a few commands, and there was no difficulty. So I found some articles on the Internet and found that these articles are rare and do not know what to say. Instead of simply writing a few commands, you can copy and paste the content in the manual without any sense of continuity. You don't know where to start. In short, I want to write a course that anyone can understand, a beginner can understand, a developer can understand, and a developer can understand.
Ii. Overview
In this tutorial, let's talk about the following parts:
Git local repository details
Git remote repository details
Git branch management
Git tag management details
GitHub Usage Details
Git global configuration details
Git and GitHub Summary
Note: In this tutorial, you can only use Git to work. As for Git, if you want to learn more about Git or want to become an expert in the Git field, I would like to say that this is just a start-up. Also, I would like to say that Git is just a tool. The purpose is to improve our work efficiency. We do not need to do it, nor do we need to waste time on research tools, as long as we use it, hey! Maybe some bloggers disagree. It's just my personal opinion. Don't try it!
GitHub Tutorials:
GitHub tutorials
Git tag management details
Git branch management
Git remote repository details
Git local Repository (Repository) Details
Git server setup and Client installation
Git Overview
3. Install Git on Windows
Note: Please download http://msysgit.github.io /. I will not demonstrate the specific installation process. Simply double-click the installation. After the installation is complete, a Git bash icon will be generated on the desktop. Double-click to open it and a command line window like this will pop up. For details, refer:
Now, we have installed Git! The basic configuration is as follows:
12 |
$ git config --global user.name "Your Name" $ git config --global user.email “email@example.com” |
Note: I set the following settings based on my situation (for example ):
12 |
$ git config --global user.name "chenmingqian" $ git config --global user.email “mingqian_chen@163.com” |
We mentioned in the previous article that Git is a distributed control system. Therefore, each client must set your name and email address. In this way, it is easy to tell which user submitted the Git version! You can see that git config is followed by the -- global parameter, which indicates that all Git Repositories on your machine will use this configuration, however, you can also specify different user names and mailboxes for different warehouses. This will be explained in later articles. I will not describe it here, hey! If you are interested, You can google it in advance.
4. Create a local repository
1. The version library is also called a repository.
A version library or a Repository. The English name is Repository. To put it bluntly, all files in this directory are managed by git and will be recorded no matter what operations you perform, including: adding, deleting, and modifying files will be recorded for subsequent tracking and modification of related records, or even restoration. Now, we will create a version library in our client (I demonstrate the Windows client here, and the operations on other clients are the same:
As you can see, you can create an empty directory under/c/Users/root/to abbreviated project name. Note that in Windows, the directory name should not be in Chinese. Otherwise, the trojan may occur and I am not responsible. Hey, ^_^ ......
2. Change directory to Repository
Run the git init command to initialize empty Git repository in c:/Users/root/pro /. git/, initialize an empty directory with the path c:/Users/root/pro /. git /. You can see that a hidden directory is generated in the pro directory. go to the git directory. You can see that there are many files in the directory. Do not modify or modify the files on the machine. The files here are used to control and manage the version library. As for the specific role of the file, we will explain it in the subsequent articles. If you want to know more about it, You can google it first.
3. Add files to the local repository
Next we will add files to the version library. Note that only text files can be tracked and managed in the version library, such as txt files, js files, PHP files, and java files, all program codes are acceptable. However, although binary files such as videos and images can be managed by git, they can only record the size and cannot track the specific changes. Everyone understands. Now let's add a readme.txt file. Its content is as follows:
123 |
This is git test . Git is a version of the best controller. …… |
The new readme.txt file must be in the pro directory. Otherwise, git cannot manage the file here! Next we will put a file into the version library.
1). git status Command
Run the git status Command first, as shown in figure. You can see that we have added a new file readme.txt to the gitrecord, and the system prompts that this file has not been submitted. Run the git add command to submit the file.
2). git add command
The git add Command tells git what file we want to submit to the repository. You can see that there is no prompt after we execute the git add readme.txt command. The submission is complete. The following uses the git commitcommand to submit the readme.txt file to the version library.
3). git commit command
1234 |
$ git commit -m "add readme.txt" [master (root-commit) e5d662b] add readme. 1 file changed, 3 insertions(+) create mode 100644 readme.txt |
You can see that we use git commitcommand to submit the readme.txt file. The prompt is: 1 file changed, 3 insertions (+). A file is changed and three lines of content are inserted. It is consistent with the three lines added above. Hey! The following is a brief description of the git commit command. The parameter-m is followed by the version description for this submission. You can enter any content, but it must be noted that, it is best to write meaningful instructions for later viewing.
4). git status Command
Finally, run the git status Command to check the status of the version library. If there is no content to submit, it means that we have successfully added a file to the version library.
4. Summary
1) initialize a Git repository and use the git init command
2) Add the file to the local Git warehouse in two steps:
Why does it take two steps to add a file in Git? Add and commit. Hey, because the commit command can submit multiple files at a time, you can use the add command multiple times. The following is a case: (we often use this case)
1234 |
$ git add file1.php $ git add file2.php $ git add file3.php $ git commit –m “add file1.php file2.php file3.php” |
Now, we have created a local git repository and added files to the repository to explain how to manage the local Git repository, there is a lot of content for you to read!
For more details, please continue to read the highlights on the next page: