Configure Github and text3github in Sublime text3
1. Install Git
Go to the Git official website to download the Git installation file for the corresponding environment.
I installed win10 on D: \ ProgramFiles \ Git. Right-click the desktop and select the following two red boxes.
Ii. Configure and generate a key in Git
Choose "start"> "cmd" to go to the command line and enter the working directory. Run the following command to set your own user information when Git submits code.
git config --global user.name "username"git config --global user.email "username@email.com"
Run the following command to view the Configuration:
git config -l
When using Sublime Text, you also need to set the push. default parameter. There is no problem when using the command line window. When using the push command in Sublime Text, you are prompted to set this parameter.
The push. default parameter is mainly used to set the policy for executing the push command. The main options are as follows:
Nothing: Do not push anything
Matching: Push all matching branches (default)
Tracking: Push the current branch to whatever it is tracking
Current: Push the current branch
Here you need to manually set it to the default value:
git config --global push.default matching
Go to the Git installation directory, find the git-bash.vbs, run it, and execute the following command:
ssh-keygen -t rsa
The program will prompt you to enter the name of the key, for example, enter mu, and press Enter.
Then you will be asked to enter a password, which will be provided when you use the key in the future. You can enter or press enter without entering it. (either input or not, you are required to confirm it once ). After confirmation, the program will generate a key pair stored in the current folder:
C: \ Users \ Administrator [replace this with your username] \. ssh
The key is divided into two files, one private key (mu) and one Public Key (mu. pub ). The private key is saved on your computer, and the Public Key is handed over to the project owner and added to the server. You must have the private key that is paired with the public key of the server to access the code library on the server.
3. Connect to Github
Visit the Github homepage, register an account, and log on.
In the upper-right corner, find Settings-> SSH keys-> Add SSH key-> copy all the text in the Public Key (id_rsa.pub) file-> Add the SSH key public Key on GitHub.
In this way, you can use git to connect to the repository on github.
4. Install the Git Plugin in Sublime text3
Install the agent through the Git plug-in on Github at https://github.com/kemayo/sublime-text-git. There is an installation method there. Copy it below
Package ControlThe easiest way to install this is with Package Control.If you just went and installed Package Control, you probably need to restart Sublime Text before doing this next bit.1·Bring up the Command Palette (Command+Shift+p on OS X, Control+Shift+p on Linux/Windows).2·Select "Package Control: Install Package" (it'll take a few seconds)3·Select Git when the list appears.Package Control will automatically keep Git up to date with the latest version.
In Sublime, use the shortcut key Ctr + Shift + P to call up the command line and enter "Package Control: Install Package". Wait until the installation is successful. Click Preferences> Package Setting on the toolbar, the Package Control column appears. As shown in
After installing the Git plugin, In the toolbar, choose Preferences> Package settings> Git> Setting> Default and set "git_command": false to "git_command": "D: /Program Files/Git/bin/git.exe "; this directory depends on the local Git installation directory.
5. Use Git plug-in Sublime text3
1. Sublime text3 menu bar-> Project-> Add Folder to Project Add the working directory to the sidebar.
2. Run "Ctrl + Shift + p" to open the command window and enter "Git: init" to initialize the git environment.
3. Enter "Git: add" to add new and modified files.
4. enter "Git: commit" for submission. Sublime Text will automatically jump out of a Text file. You can enter the modified comments at the top of the file. When the file is closed, the commit operation is automatically triggered. In fact, comments is used as the git commit-m parameter.
5. Create a new repository on Github with the same name as the local working directory, switch to the working directory, and run the following command:
Git remote add origin git@github.com: benjamin-zuo/Arrow. git
The git@github.com: benjamin-zuo/Arrow. git is the SSH clone link.
6. Run git pull origin master in the working directory to update the file
7. Run git push orgin master in the working directory to submit the file.
8. Go back to Github and refresh the submitted results.
Then, you can directly enter git: pull, git: push, git: diff, and so on in the Sublime text2 command window to perform related operations.
Vi. FAQs
1. Execute the following statement to report an error
Git remote add origin git@github.com: defnngj/hello-world.git
Error message: fatal: remote origin already exists.
Solution:
Git remote rm origin first
Then execute:
$ Git remote add origin git@github.com: defnngj/hello-world.git
2. Execute the following statement to report an error
Git push origin master
Error message: error: failed to push som refs .......
Solution:
$ Git pull origin master // first pull the files on the remote server github and then push them.
3. Add multiple URLs to the remote database using git
Add the first address git remote add origin url1
Add the second address git remote set-url-add origin url2
Add the third address git remote set-url-add origin url3
Note: When you use git to push origin master, you can push multiple URLs of origin. However, when you use git pull, you can only pull one url address in origin, by default, this url is the first address you add to the origin. You can use the git config-e command to change the default url in the Git config file.