Day 01 Gitee basic concept

Day 01 Gitee basic concept

1. What is a warehouse

In the concept of Git, the warehouse is .gitall the files in the folder where you exist in the directory, including hidden files. The Git program will look for the .gitfiles in the current directory and the upper-level directory . If they exist, they will .gitbe the files in the directory. All the files at the beginning of the folder are treated as files that you need to manage, so if we want to use a folder as a Git repository, you can execute it through the terminal (Window is Cmd or PoewrShell or Bash) under that folder

git init

In this way, the folder you expect becomes a Git-managed repository

Second, what is the version

Strictly speaking, there is no concept of version in Git, but people have just developed such a thing. In Git, the basis of counting is submission, which is what we often call Commit. Every time we make a change, we can generate a submission. When the submissions are accumulated and can be used as product finalization, a mark is marked on the current Commit, and we call this mark how many versions, then even if a version is completed, the mark itself is called a Tag. Please note that In Git, the version is only a certain submitted tag, and has no other meaning. Git itself only has the tagging function, and there is no version function. The version function is extended based on the Tag, and Git itself does not.

Three, what is a branch

This is one of the most important and most commonly used concepts and functions in Git. The branch function solves the problem of the stability conflict between the version under development and the online version. During the use of Git, our default branch is generally Master. Of course, this It can be modified. We completed a development in the Master and generated a stable version. Then when we need to add new features or make changes, we only need to create a new branch, then develop on that branch, and merge into the main branch after completion. can

Fourth, what is submission

Submission is also a very important concept in Git. Git's version management is actually the management of submissions. In the entire Git repository, the form of code existence is not one-by-one code, but one-by-one submission. Git Use a hexadecimal string with a length of forty bytes to identify each submission, which basically ensures that the identity of each submission is unique, and then by organizing a submission list sorted by time, it constitutes what we call Branch, please note that the branch is essentially just an index, so we can roll back and modify at will, even if it is lost for some reason, we can also rebuild. In addition, about the storage method of Git: Git only stores modified Part, and will not store the entire file, so please do not delete the entire folder content of the folder, unless you are sure you no longer need it, otherwise do not delete

Five, what is synchronization

Synchronization, which can also be called pull, is a very frequent operation in Git. Unlike SVN, all Git repositories are equal. Therefore, in order to ensure code consistency, try to do it before each operation as much as possible One synchronization operation, specifically, execute the following commands in the working directory:

git pull origin master

Which originrepresents your remote repository, you can command git remote -vview, masteris the name of a branch, if you are other local branches, please replace the names of the other branches, and the other, because the remote repository with your local repository there may be a conflict, so when there is a conflict Please refer to how to deal with conflicts in the advanced chapter

Six, what is push

Like pull, it is also a very frequent operation. When your code is updated, you need to update to the remote warehouse. This action is called push. The command executed is the same as the pull, except that pullthe word is changed to pushSimilarly, if there is a remote repository local repository you do not update, then before you need to make a push synchronization, if you are sure you do not need a remote update, adding, when push -foption, you can force push, note: In collaborative development, I do not recommend this, because it is likely to cover other people's code

Push code example:

git push origin master

Example of forced push code:

git push origin master -f

7. What is conflict

When using Git for development, if only one person uses it, there will be basically no conflicts, but in the case of multi-person cooperative development, conflicts are normal. For how to deal with conflicts, please refer to the advanced article How to deal with code conflicts this section

8. What is merger

Merge This command is usually used to merge two branches. It is generally used for local branches. Pull commands are used for remote branches. The function of this command is to merge the branch to be merged with the target branch. Note that this command will only merge differences in previous versions, the two branches of the organization will be re-submitted to the current history index based on submission time, it is only likely to generate a conflict but will generate a submission, if you do not want to generate this submission, plus --baseparameters can

Nine, what is temporary storage

This is both a concept and a command, and its meaning is literal, and its function is to temporarily save the work you are currently doing, and then do other things on this basis, and then transfer it after you finish other things. Come back and continue, note that the temporary storage is only for your last change, that is, all changes to the current version are counted as the specific execution command:

1. Temporarily save the current changes:
git stash
2. Restore the last temporary changes
git stash pop
2. Check how many staging
git stash list

10. What is revocation

The undo command is used very frequently. For some reasons, we no longer need our changes or there is a problem with the new changes. We need to roll back to a certain version, then we need to use the undo command, or this should be translated Success reset is more appropriate. The specific commands are as follows:

Undo the current modification:
git reset --hard

Please note: The above command will completely reset your changes. If you want to keep some files, please use checkout + file path command to undo the changes one by one

If you want to reset to a version that can be --hardchanged to Commit a specific id, such as:
git reset 1d7f5d89346

Please note that your modification still exists at this time, but the version number of your last submission has become the version you want to reset. If you want to discard the modification completely, just add the --hard parameter.

Guess you like

Origin blog.csdn.net/A1L__/article/details/111874414