1. installer sudoapt-getinstallgitsudoapt-getinstallgit-core2. Then update the repository gitclonegit through the command: // Repository
1. Installer
Sudo apt-get install git
Sudo apt-get install git-core
2. Use the command to update the version library.
Git clone git: // git.kernel.org/pub/scm/git/git.git
3. Create a new version Library
Mkdir gittutorch
Cd gitturtorch
Git-init-db
In this way, an empty version library is created and a subdirectory named. git is created in the current directory. You can use ls-a to check the content and pay attention to the following three items:
A file named HEAD. Let's check its content now:
$ Cat. git/HEAD
The contents of the HEAD should be as follows:
Ref: refs/heads/master
We can see that the content in the HEAD file only contains an index information, and this index will always point to the current development branch in your project.
A subdirectory named objects contains all objects in your project. We do not need to know the content of these objects directly. We should be concerned about the data of projects stored in these objects.
A subdirectory called refs is used to store indexes pointing to objects.
Specifically, the subdirectory refs contains two subdirectories: heads and tags, just as their names mean: they store the indexes of the headers of different development branches, or the index of the tag you use to calibrate the version.
Note: The master is the default branch, which is why. git/HEAD points to the master when it is created, although it does not exist at present. Git will assume that you will start on the master and expand your future work, unless you create your own branch.
In addition, this is just a conventional habit. In fact, you can call your work branch any name, instead of having to have a master branch in the version library, although many git tools think that the master branch exists.
Now a git version library has been created, but it is empty and cannot do anything. The next step is how to implant data into the version library.
Step 4: implant content tracking information: git-add:
To be concise, we create two files as exercises:
$ Echo "Hello world"> hello
$ Echo "Silly example"> example
Use the git-add command to add these two files to the version library file index:
$ Git-add hello example
Git-add is actually a script command that calls git-update-index, the git kernel command. Therefore, the above command is equivalent to the following command:
$ Git-update-index -- add hello example
If you want to clear a file from the git directory tracking system, you can also use the git-update-index Command. For example:
$ Git-update-index -- force-remove foo. c
Git-add can include all contents in a directory under content tracking, for example, git-add./path/to/your/wanted. However, before doing so, you should first clear some files that we do not want to trace, for example, the gcc compiled *. o file, vim swap file. *. swp and so on.
A clear concept should be established: git-add and git-update-index only refresh the git tracking information, the content in the hello and example files is not submitted to the git content tracking scope.
Step 5: Submit the content to the version Library: git-commit
Now that we have refreshed the Git tracking information, let's look at the status of the version Library:
$ Git-status
We can see the git status prompt:
#
# Initial commit
#
#
# Updated but not checked in:
# (Will commit)
#
# New file: example
# New file: hello
#
The prompt message tells us that two new files are added to the version library, and git prompts us to submit these files. We can use the git-commit command to submit them:
$ Git-commit-m "Initial commit of gittutor reposistory"