Java_home =/usr/local/jdk1.5
Classpath =.: $ java_home/bin: $ java_home/lib/tools. jar: $ java_home/lib/dt. Jar
Android_sdk_home =/home/lsj/tools/Android-SDK/platform-Tools
Path =.: $ classpath: $ path: $/home/lsj/Android/bin: $ android_sdk_home
1. Install git
> # Sudo apt-Get build-dep Git-core Git-Doc
This will install the git-core and git-Doc dependent libraries.
Next, go to the official website to download the GIT source code package. Decompress the downloaded git package.
Execute the following commands in the decompressed directory to compile git
> # Make prefix =/usr/local all Doc
Install git
> # Sudo make install-Doc
In this way, your git can be used by all users on the computer.
You can use the following command to view your git version.
> # Git -- version
2. Configure git
Because git does not have a central repository as SVN does, you do not need to provide the user name and password for the central repository. But we still need to tell
You need to pass some information to git through the user name and email address. This information is usually set to global. User. name must be set here.
And user. Email. User. Name is the name displayed when code is submitted. User. Email can be used by other developers to contact you.
> # Git config -- global user. Name "your name"
> # Git config -- global user. Email "youraddr@xxx.com"
Then we can run the following command to check whether the modification was successful.
> # Git config -- Global -- list
We should see the information we Just configured.
In addition, you can adjust the display color of git to identify different changes.
> # Git config -- Global color. UI "Auto"
3. View git help
> # Git help
Command to view git commands
The most commonly used git commands are:
Add add file contents to the index
Bisect find by binary search the change that introduced a bug
Branch list, create, or delete branches
Checkout checkout a branch or paths to the working tree
Clone clone a repository into a new directory
Commit record changes to the repository
Diff show changes between commits, commit and working tree, etc
Fetch download objects and refs from another Repository
Grep print lines matching a pattern
Init create an empty git repository or reinitialize an existing one
Log show commit logs
Merge join two or more development histories together
MV move or rename a file, a directory, or a symlink
Pull fetch from and merge with another repository or a local branch
Push update remote refs along with associated objects
Rebase forward-port local commits to the updated upstream head
Reset reset current head to the specified state
Rm remove files from the working tree and from the index
Show show various types of objects
Status show the working tree status
Tag create, List, delete or verify a tag object signed with GPG
To view the specific git commands, run the following command, for example, view the clone command.
> # Git help clone
Now that we have configured our git, we can create our project. I will write it tomorrow.
The last time I learned how to install and configure git, I started to create a project today.
1. Create a version Library
Compared with SVN and CVS, git version library creation may be quite different. To create a version library in git, you only need to execute simple commands in your project directory.
For example, create a project directory and initialize our version library under this directory.
> # Mkdir Project
> # Cd Project
> # Git init
After executing git init, execute the following LS-A. We can see that a. Git directory is generated under the project directory, which is used to record the version information we submitted.
The project directory is the project directory we work on.
2. Add and submit a file
Through the above steps, we only obtained an empty version library. Next, we will add files to the version library. For example, we have created a new file hellogit. C.
> # Touch hellogit. c
How to add this file to the version Library requires two steps: first, use the GIT add command to tell git to add this file to its index. Then execute git commit to submit.
This process is the same as that of SVN.
> # Git add hellogit. c
> # Git commit-M "first Add"
Commit can be used to list files, such as git commit hellogit. c hello. C-m "second add ". If nothing is written, all changed files will be submitted.
-The quotation marks behind m are mandatory commit logs, which are used to explain the changes you have made.
3. View changes and logs
If we modify the content of hellogit. C.
> # Git status
Command to view the changes to the local project and version library. In this example
# On branch master
# Changed but not updated:
# (Use "Git add <File>..." to update what will be committed)
# (Use "Git checkout -- <File>..." to discard changes in working directory)
#
# Modified: hellogit. c
#
You will see the following information, which shows that we have modified hellogit. C. But it has not been submitted to the database.
We need to execute the commit command to tell git changes. Note that this time you don't need to add any more. You only need to add one file.
> # Git commit hellogit. C-M "second Add "\
-M "add Mian"
Note that git supports multiple-M and multi-line annotations, which is great.
Then we can use git log-L to view the submitted log files.
> # Git log-l
Git re-creates a branch project in a project (used to create a branch, a new project, or the original project)
1. Enter a folder, which is the directory of a new project.
2. Run the LS and CD commands to enter the directory.
3. Use SSH swanr (server abbreviation) Gerrit LS-projects-t to view some projects and structures on our servers
4. use git clone swanr: Android/platform /................... /apps/launcher-B hello_branch name (branch name)
5. enter the new cloned project, import the new project to eclipse, and use LS and CD to enter the first directory of the new project. Then, use git branch to check that it is the master branch.
Here you can create a branch (GIT branch branch_name) that is the same as the main branch, and then there will be two branch names in git branch. Then you can use git checkout branch_name again to switch to another branch.
6. modify some items in the Eclipse project and use git status to record them.
7. Use git commit-a "commit message" to submit the request and then use git to push origin branch_name (local name): branch_name (Master name) directly)
First run the GIT command to clone an original project to a new directory, and then modify the project. The operation is the same as before.
Note !!! When the code is finally submitted to the remote server
Use git to push origin [local_branch]: ca01_r94_1
Note: local_branch indicates the local branch name.
The GIT server automatically creates a ca01_r94_1 branch at the remote end.
Next time you want to clone this branch in the new directory, add-B ca01_r94_1 to the end.
For example, git clone swanr: Android/platform/vendor/eee168/packages/apps/taskmanager-B ca01_r94_1
And so on
Git command
Create a project
ssh swanr gerrit create-project --name android/3rdparty/apks --parent virtual/android-common
Modify project
ssh swanr gerrit set-project-parent --parent virtual/android-common android/3rdparty/apks
View the project structure (commonly used to create a branch step 1)
SSH swanr Gerrit LS-projects-T clone Project (usually used to create branch step 2) git clone swanr: Android/platform/packages/apps /.. /launcher view the directory structure of the entire branch SSH swanr Gerrit LS-proejects-t create branch git branch name (commonly used in step 3 of new Branch) commit branch git checkout name (often used to create branch step 4) Delete branch git branch-D name view branch git branch commit ----- clone a project git clone Swanr: Project pathname Chen git commit-A submit to local branch git push origin master: Master local modification completed, push to the server git add Add add local modifications ---------- git daily Common commands git pull -- rebase get the latest version of git status on the Server View local modifications git Add/RM add or delete local modifications git commit-a Save the modification to the local git push origin master: update master to server ----------------------------------- Modify git commit-Amend to modify the latest commit information (before pushing) git rebase-I origin/branch (hedad) modify the information submitted in the middle ------ git Add add resources git commit submit to local git fetch origin and git rebase-I origin/master to synchronize local, server git P Ush origin master (local branch): If the master (server Branch) appears! [Rejected] The premise is that the Code has been submitted to the local machine, so git fetch is required, and then git rebase-I origin/branch name Chen merges the conflicts and checks the status git status again, now the name of the both modified file appears. Add the GIT add file name and merge git rebase -- continue again. Finally, submit the code to the server: git push origin local: remote.