Another powerful thing about sublime text is that it provides a very rich plugin that can help programmers to develop for most languages. These plugins are easy to install through its own package controll (packet Management) component. Common plug-ins commonly used include:
Zen Coding--a quick way to write html/css code
jquery Package-The jquery code bundle, jquery's auto-incomplete functionality brings great convenience to jquery programmers.
JS format--JS formatting tool
Jsminifier-JS compression tool, based on Google Closure compiler.
Git--almost all the features of GIT are supported
If you are interested in these plugins, you can read this article.
My article focuses on how to use the Git plugin in sublime text to create and connect to projects on GitHub (Win 7 environment). git and GitHub I don't have a detailed introduction. Simply put, Git is a popular code-management and Versioning tool at the moment. And GitHub is an open code management platform based on Git, the most popular open source repository, and you can almost find all the best open source libraries and tools. such as Node.js,jquery,bootstrap, even # #sublime-text-2-git# #这个插件本身也放在了gitHub上.
1. Git installation
To use the Git feature, git installation is a must. Git is not a github, you can download the git installation file on the GIT website. The classmate with GitHub installed already has a portable git version on the machine, and my C:\Users\Owen\AppData\Local\GitHub\PortableGit_ 93e8418133eb85e81a81e5e19c272776524496c6 "in the directory. # #需要注意的是, this git is not suitable for use as a machine global git app, because as GitHub updates, the string of characters behind this git directory file will change, causing the git run file set in path to not be used. # # So the recommendation is to install pure git and set its bin/cmd directory to the PATH environment variable. Mine is "D:\IDE\Git\cmd".
After the installation of the students can use the git--version command to see if the installation is successful.
2. Git config, connect with GitHub
Configuring Global parameters
Git configuration mainly includes the user name, mailbox settings, as well as the generation of SSH key public key and so on.
Run the command first to set your own user information when Git commits the code.
git config --global user.name "username"git config --global user.email "[email protected]"
You also need to set the Push.default parameter when used in sublime text. There is no problem when using the command-line window, when you use the push command in sublime text, you are prompted to set this parameter.
The Push.default parameter is mainly set in the policy of executing the push command, the main options are the following:
Do not push anythingmatching : Push all matching branches (default)tracking : Push the current branch to whatever it is trackingcurrent : Push the current branch
Here we manually set the default values:
git config --global push.default matching
Generate SSH Key
Go to the Start menu, find "Git Bash", run it, and execute the following command:
$ ssh-keygen -t rsa
The program prompts you to enter the file name of the key, such as GitHub, and press ENTER. You will then be asked to enter a password that you will need to provide in the future when using the key. You can enter, or you can not enter a direct return (regardless of input or not input, will ask you to confirm once). Once the confirmation is complete, the program will generate a pair of keys to be stored in the following folder:
C: \ Users \ Administrator [replace here with your username] \. Ssh
The key is divided into two files, a private key (Github_rsa), and a public key (Github_rsa.pub). The private key is saved on your computer, and the public key is added to the server by the project owner. The user must have a private key that is paired with the server's public key to access the code base on the server.
Note "For the safety of your project code, keep your private key properly!" Because once the private key leaks, it can cause the code on the server to be leaked!
Connect to GitHub
The next step is to bind your native git settings to GitHub so that the commit code from your machine does not mention the repository.
First of all, of course, register an account with github.com and log in. Then find "Account Settings" from the upper-right corner of the page and open it.
Then click Add SSH key in SSH keys, copy all the text in the public key (github_rsa.pub) file, click "Add Key" to complete the SSH key public key on GitHub to add.
So on your machine, you can use Git to connect to the repository on GitHub.
3. Sublime Text 2 Install git plugin
Sublime text provides a variety of ways to install plugins:
One is to use the package control component (recommended), and when you open the Install Packages console, you can simply enter Git to see
For the package control installation, you can refer to this article [Article] (http://www.iplaysoft.com/sublimetext.html)
ctrl + `has been unable to open the console, and later guessed that it was a shortcut conflict,
Then go to the shortcut key settings and change the console shortcut from ctrl + `to ctrl + shift +`.
Then open the console with the new shortcut key, paste the import code, run it, and then use install to call up the installation and create the library.
The other is to download the code directly from git and put it in the Packages directory of sublime text. The general path is:
"C: \ Users \ <username> \ AppData \ Roaming \ Sublime Text 2 \ Packages".
This time sublime text just installs the Git plugin, but can not use git command, need to modify SUBLIMT text for git configuration file "Git.sublime-settings", this file is generally in your account directory, such as:
C:\Users\Owen\Git.sublime-settings, if not, create this file.
Add the following to this file
"git_command": "D:/IDE/Git/cmd/git.exe"
(It's strange that you can't set it in preference, it's probably my "program Files" directory containing spaces)
is pointing to the Git.exe file in your git program.
4. Using the Git plugin in sublime text
To this location, all the local environment configurations have been completed. Next talk about how to use the Git plugin in sublime Text to connect to GitHub.
First, in sublime text open the project directory that you want to sync with git, and mine is "D:\Workspace\git\SublimeGitTest".
Then use "Ctrl+shift+p" to open the Command window and enter "Git:init" to initialize the Git sublimation. ST2 will let you choose the git directory you want to initialize and choose your project directory.
After that, you can use GIT commands normally.
Use Git:status to view the current state.
When you enter a command, the local item change status appears in the Pop-up window.
Choose the changed file, you can see the changes directly, Git's diff function:
The next step is to add the newly added file with the Git:add command.
Select "Including untracked files" to add the newly added readme.md to the changes.
Use Git:commit to commit the changes. Sublime text will automatically jump out of a text file, you can enter the comments of this change at the top of the file, and then close the file directly, you will start a commit operation. And will you enter the parameters of the comments seat-M. This is very convenient, more convenient than the command line to run a commit with the-m parameter to add comments, and can be arbitrarily modified. Ctrl+w The commit operation is triggered automatically while the file is closed.
The next step should be to add the remote repository (repository), and in sublime text I never find this command, so I can only execute it with the command line.
Of course, the last thing to do is to create a repository on GitHub, as follows is a repository that I created with the same name.
Note Here the SSH protocol is selected.
Then switch to the project directory at the command line and enter the command to add remote repository:
git remote add origin [[email protected]:owenXin/SublimeGitTest.git](mailto:[email protected]:owenXin/SublimeGitTest.git)
Then go back to sublime Text and you can use the Git:push command to upload the code. But something strange happened and there was a mistake.
Checked, there should be no host (master), but sublime git does not support adding parameters, so you can only go back to the command line to execute the push command.
Successfully completed.
Then modify the file and try the push from sublime Text again. From add to commit to push, there was no problem and the push was successful.
Once again on GitHub, you can see the new files and the contents of the sublime Text push.
OK, so far sublime Text 2 has been able to use the GIT function smoothly, although the initialization process has some twists and turns, but finally can work. I hope this article can be helpful to friends who want to use sublime text, really very useful!!
For more information on how to use Git plugins, refer to the plugin on GitHub: # #sublime-text-2-git##
Wen/WPI Fukang (Jane book author)
Original link: http://www.jianshu.com/p/243d4a93ff05
Copyright belongs to the author, please contact the author to obtain authorization, and Mark "book author".
Sublime Text using git plugin to connect to GitHub