What is Git?
- Wikipedia says Git
- Distributed version control software, originally designed for better management of Linux kernel development, has gradually developed into independent version control software, many large software use Git for version management control
Second, the Git VSSVN(Subversion)
- Note that there are not only two types of version control software. These are the two types of version control software that are used most of the time
- Git is distributed version control software, but Git also has centralized repositories or servers that tend to be distributed version management. Svn does not.
- Git stores content as metadata, while SVN stores content as files. Git directory is a clone of the remote repository located on your machine
- Git does not have a global version number, while Svn does, which is a current flaw in Git. However, you can add a tag to Git to compensate for this. When the project is tested, I commit once, the version number +Test is submitted, the overall regression Test of the project is completed, and when the submission is ready to go online, I submit again. The submission information is the version number only. The method may not be very good, but it’s clear.
- Git’s content integrity is superior to SVN’s: Git’s content store uses the SHA-1 hash algorithm to ensure code integrity and not be corrupted
- If Git is Offline, you can view all the logs by entering Git log in the Terminal
- There are a lot of, not to repeat, most of the online information is complete, even if you don’t know the difference between the two, in the process of using, slowly will know, the world is difficult, if you put your heart into it…
Three, primary use
- If you don’t find this article easy to follow, you can use Git here
- Git clone + git clone + git clone
- Branch: You can think of a tree where the trunk is the main branch, and the branches are the branches. You can create branches at will, and branches are important throughout the project.
- Git branch -r: View branches of remote repositories
- Git branch -a: View all branches
- The branch of the project I worked on was always created according to this rule: Master branch (the master branch, no matter what the case is, keep the master branch running properly) Developer branch (a branch in the development phase, normally speaking, For example, my branch is Sunxu. Every time I do local development, I switch to my own branch for development. After the completion of development and testing, I submit the branch to the remote warehouse and directly merge with the developer branch. Everyone else does the same thing, submitting branches to Developer, merging branches to Developer, and finally merging with master
- Because such benefit is that once I submit (commit) code conflict with others, I can roll back directly, is an issue that cannot be resolved in the rollback, I also can let other developers to make a forced to submit, in such a remote warehouse code can run, and does not affect other people’s code, just increase their workload, Do you think that if your colleagues are willing to work overtime because of you, you can live with your conscience? So try not to make trouble for others
- Git status Check the status of local files. I’ve made it a habit to check the local file status before each commit.
- Git status command: git status command: git status command: git status command
- Git add: [git add.] / git add. / git add. / git add. / git add.
- Git status git status git status git status git status git status git status git status git status It’s just adding a snapshot locally.
- Git commit will jump to the interface of adding the submission information. Vim is easy to use. The information can be filled in or not filled in, but I suggest filling in all the information, because every submission is meaningful
- Git commit -m: The database to read and write git commit -m: The database to read and write
- Git push: if a branch is pushed to a remote server, the code will be merged automatically. If there is a conflict, it will be notified and the commit will not succeed
- At this point, a complete change, submission, push all completed, very simple, a day can be used
Four, use experience
- Git has a graphical operation software client, for those who do not like the command line, you can directly download: SourceTree. But I think as a programmer, more or less you have to be able to command the line, after all, for women who don’t understand, this is the perfect seduction skills
- When iOS developers use SB for team development, try to keep everyone’s SB files separate and do not put them together as they may cause conflicts. Even if you simply open the SB file and look at it, Git will keep track of it and its changed state. So separate as much as possible. If you need to checkout someone else’s SB file, you can checkout git status, list the SB file you just checked out, and checkout git checkout + file name to switch the SB file back to its original state
- Pull merge branch: I’m not used to using Git pull. Pull does pull and merge, but sometimes there are problems, so I try to avoid problems using:
-
Git fetch Origin develop
-
Git merge origin/develop
-
- Roll back: It doesn’t matter if you rollback code that doesn’t have a push on your site. You can use reset, but I prefer to use Git to rollback code that doesn’t have a push on your site. Just submit the version you want again and push it. You can imagine a tree that has a leaf that doesn’t look good and you want to have it regrow. Reset means removing the leaf from the tree, and revert means that it’s not growing anymore, it’s growing from its parent, it’s jumping over it, it’s merging with its parent. But I feel revert is better.
PS
- Work as a team, try not to make trouble for colleagues, you may not, you may make mistakes, but have the courage to take the mistake, say thank you more
- In the company of three there must be a teacher. When code or logic is unclear, don’t try to bypass it and leave it to someone else. You can only get more and more of them, and the growth of skills comes from the number of dead knocks and pits.
- You may not have encountered Google, Stack Overflow, try to solve their own, harvest endless
- If you say you can’t access Google, check out my article on Science Online 2017