"The authoritative guide for Android Programming"-Reading Notes (c) A preliminary study of Git
Version Control-git
Why Use version control
What is version control? Why should I care about it? Versioning is a system that records the changes in one or several file contents so that future revisions of a particular version are reviewed. In the example shown in this book, we only version control the text file that holds the software source code, but in fact, you can version control any type of file.
If you are a graphic or web designer, you may need to save all revisions of a picture or page layout file (which is perhaps a feature you are very eager to have). Using a version control system (VCS) is a smart choice. With it, you can trace a file back to its previous state, or even roll the entire project down to a point in time in the past. You can compare the details of the file and find out who made the change, find out what caused the weird problem, and who reported a feature defect and so on. Using a version control system also means that you can easily revert to the original image even if you change the file in the whole project by deleting it. But the extra workload was minimal.
installation of Git
Install git under Windows. We first visit http://msysgit.github.com/
Initializing a new warehouse in the working directory
Right-click in the working directory (for example I'm in E:\example\GeoQuiz) and choose Git Bash.
Let's look at the configuration first
$ git configt–list
There is no user information for me. User information is important, and each time git commits it, it references these 2 messages, stating who submitted the update and is permanently included in the history along with the update:
Git Config–global User.Name < username >
Git Config–global User.email < e-mail >
$ git config–global user.name "lijing"
$ git config–global user.email [email protected]
After executing git config–list you can see that my user information has been added to the configuration.
Now we execute the following instructions
$ git init
and view the status after initialization
$ git status
The repository is created, but the source code is not committed, and the system prompts you to use git add to submit
$ git Add.
Submit all future
$ git status
The view will find that the build is not committed, there is a. Gitignore in the original directory, the contents are as follows
. gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
. Ds_store
/build
In this step, I don't know if this file was created by Git or created by Android Studio. I tried to create a new project and found that there was also a. Gitignore in the new project. Description This is created by Android Studio. This file can also be created on its own, and it has its own rules to choose which rules-compliant files are not submitted to the version controller.
At this point our new warehouse has been created. Then submit the following
$git commit–m
Try to add a new file at once
We add a Readme.txt file directly to the catalogue and write something about it. And take a look.
$git status
Here you can see the newly added files.
$git Add. or $git Add Readme.txt
Then submit
$git commit–m "Create a Readme file"
Create a remote Data Warehouse
Now, to view my source code, I have to upload it to the server. I chose http://git.oschina.net.
First I add a remote repository
$git Remote Add Geoquiz https://git.oschina.net/canglin/GeoQuiz.git
And take a look.
$git remote-v
Because it was the first time
$git Push Geoquiz Master is definitely not possible because conflicts with code on the server must be merged once.
$git Pull Geoquiz Master
$git Push Geoquiz Master
Http://git.oschina.net/canglin/GeoQuiz success, access to this URL can get the source code
"The authoritative guide for Android Programming"-Reading Notes (c) A preliminary study of Git