Git is a very power-giving version control tool. I understand versioning refers to the various stages of project development control, such as project release version is actually a stable version of the project development after the maturity. (How to do, I like to see this sentence I do not understand the TNT)
In the course of the development of the previous small-time, if I want to modify a project, but I am not sure if the modification is valid, I will copy a project to save, and then to develop changes to the copy, which has several disadvantages: 1, the source code, various resource files and dependent libraries to save all sometimes the project too General Assembly to occupy additional space 2. The path is usually changed after the copy, this will also have to reset the include path, library directory, 3, sometimes the changes can not be recorded, they can not clear and efficient control of the project development process, the solution becomes a folder for each copy of the name, such as: "Pro_ changed *" (Of course, the development process will try to avoid the Chinese path, here is only for understanding), such as various.
And git can solve the above problem very effectively: 1, git save each version is to save its modified information, that is, "add *" and so on, so as to avoid taking up additional space and can not record the modification of the problem; 2, git different branches (branching concept later) is working in the same working directory, So there's no such thing as a reset path.
Gossip does not mention, here to write about Git basic operations, to talk about their use of git understanding.
First of all, you need to download and install Git local tools, specifically do not list, there are many tutorials online. The following are basic operations:
1, in the need to build a git warehouse path right click Git Base here
2, input git init//This step is to establish a local warehouse, you can understand that the warehouse is a management of a version of a container
Once you have established the local warehouse, enter the LS-A command, and if you can see the. git folder, the Git local warehouse was successfully established and the current path is your working directory
3, input git Add//Here is the need for version control of the file into the warehouse, so that git can manage the version of the file, see someone on the Internet to make these files be git tracking, so that after the record changes and so on
Enter git Add. Finally there is a point, a point that represents the current path, which is to add all the files under the current path to the local warehouse
4. Enter git commit-m "notes"//This command is to submit changes to the local warehouse above is simple local operation, local, Focus
All right, people have some idea of the concept of warehouses, including me, 0.0, and then share how version control (simple operations, such as the Great God, welcome corrections) There will be a default main branch when the warehouse is established: Master enter git branch new_branch//new name New_ Branch Branch, New_branch content is completely copied to the master branch input git checkout new_branch//Select New_branch Branch, in which case your development will be carried out in the New_branch branch, that is, repair File change has no effect on master branch
These two steps can be combined into one step, enter Git checkout-b new_branch, new and select New_branch Branch
If you have something to do, you will need to modify the master branch first to make the previous Git commit-m "." Action submit New_branch Branch modification
Here you can use Git status to view the status of each file in the branch, if there are any changes that are not submitted, or if any new files will have a highlight input git checkout master selects the Master branch, when first: the files in the working directory will be forwarded to you before you submit Master The state of the branch; second: The file modification under the working directory is to operate on the master branch, without affecting the New_branch branch.
Personally believe that Git is based on this to achieve version control
Next is the local warehouse push (push) to the Remote warehouse: (Here you need to first in GitHub, Gitlab, and so on the project hosting platform to establish a remote warehouse, SSH configuration, they are not too familiar with, do not fraught, you are still looking for the internet on the road big God ~ ~ ~)
Enter git remote add origin git@< URL >
URLs can be obtained from the hosting platform, taking GitHub as an example:
Click on the GitHub platform's warehouse and go to the interface, then click "Clone or download"
So I type git remote add Origin git@https://github.com/gllamant/chid.git
18/2/5: This is written in the push when prompted "I don ' t handle protocol ' git@http '", which means that the wording is wrong, I changed to "Git remote Add Origin http://github.com/GlLa Mant/chid.git "Error resolution.
Another: If you are prompted for remote origin already exists, enter git remote rm origin to delete the associated error remote repository, and then do the above to reconnect.
There are other written, specific direct online search "Associated Remote Warehouse", a lot of dry goods
Enter Git push-u origin msater to push (push) The local warehouse to the remote repository
Push successful, refresh GitHub, you can see the remote warehouse out of the file you just push
-u parameter on the Internet see someone say the first push plus, then you can not add, I have not figured out, everybody attention
Finally, remember to download or clone remote Project to Local: (also need SSH configuration) git clone < URL > If you want to clone a remote warehouse-specific branch clone: Git clone-b < branch_name > < remote_re Pository_address >
Branch_name: Remote Branch Name
Remote_repository_address: Remote warehouse address, URL
Find a very detailed explanation.
This is the only point of gain; Welcome to the Guide, I wish you all a smooth study.
20180207 more: Common Git command list
Put up a picture first
Personal feeling write the thief stick ...
20180209: When you switch between versions of version control, remember to git add first. , and then submit git commit, if not, all the changes remain within the workspace, even if checkout to other branches, open the file, is still the previous version of the modified content, then git Add. And Git commit is extremely easy to modify overwrite current version content, for example: I have a,b two branches, a is the master branch, I work in branch B, and then suddenly have something to change a branch, I must first under the B branch git Add. and Git commit.
20180314 MORE: The company server changed IP, directly Meng, remote warehouse Ah, the following is the replacement of Remote Warehouse link command:
git remote Set-url origin <url>
Here are two "URLs", the first time and set together to hit the URL directly, is the command parameters, and parentheses in the current remote warehouse URL address, such as my command is:
I have slightly modified the IP, anyway is git address
git remote Set-url origin http://127.0.0.1/guol/guol.git
OK, then enter Git remote-v will find that the remote warehouse link has been replaced, the next operation is git Add. | Git commit-m "*" | Git push origin master, specific reference to this article.