To create a version library
First select a directory (try to make sure the directory name does not contain Chinese), then to this directory git bash , and then in this directory to the directory of $ git init git can be managed by the Repository (repository)
So git set up the warehouse (Gittest), in the Gittest directory will show a. Git directory, this directory is git to track the management of the repository, it is OK to manually modify the files in this directory, or change the mess, the Git repository to destroy.
If you don't see the. git directory, that's because the directory is hidden by default and can be seen with the Ls-ah command.
Workspaces and Repository workspaces (working Directory)
Is the directory that can be seen in the computer, such as the Gittest folder is the work area
Version Library (Repository)
The workspace has a hidden directory. Git, this isn't a workspace, it's a git repository.
Git has a lot of stuff in its repository, the most important of which is the staging area called stage (or index), and the first branch master that git automatically creates for us, and a pointer to master called head.
The next section on branching and head is again spoken.
The whole process is:
First step: Add or modify files in the workspace first git add to staging area
Step Two: git commit submit all the contents of the staging area to the current branch master
Note: Because git automatically created the only master branch for us when we created the Git repository, now git commit is committing the changes to the Master branch.
For example, add a file:
1, in the Gittest folder to write a file README.txt, the content is:
1 add a file called README
2. $ git add readme.txt add files to the staging area in the repository
3. $ git status look at the status at this point, as shown in:
"Changes to be committed:" means the contents of the staging area in need of submission
4, the $ git commit -m "add a file named README" content in the staging area is submitted to the current branch, note:-M after the input is the description of the submission, you can enter any content, of course, it is of great significance, so that you can easily find changes in the history record.
When the git commit command succeeds, it will prompt that 1 files have been changed (our newly added README.txt file), inserting 1 lines of content (Readme.txt has 1 lines of content).
5, once submitted, there is no work area to make any changes, then the work area is clean, you can git status view:
Now that the repository has changed, staging area has no content:
GIT work structure