本文主要介绍如何在 Sublime Text 3 搭建 Git 环境,关于这两者,就不多加介绍了,懂者自懂。我会从头开始搭建并连接 GitHub 远程仓库进行简单的代码提交更新等操作。
特别提醒:本文的操作系统为 Windows,但绝大多数步骤与 Mac 类似。
Git 安装
这边提个醒,有些同学喜欢使用 GitHub 客户端,而该客户端本身就会自带 Git 版本,一般在 安装目录/GitHub/PortableGit_版本相关字符串/cmd/git.exe
中。
需要注意的是,这个 git 并不适合作为机器全局使用,因为随着 GitHub 的更新,该目录文件后面的那串字符会变动,从而会导致之前的 Git 配置失效。
建议直接去 Git 官网 下载最新版本,安装完后将 安装目录/cmd/git.exe
加入到系统环境变量 Path 中,打开 cmd 输入 git --version 命令查看一下是否安装成功。
Git 配置
配置全局参数
这里主要配置 用户名、邮箱 以及 SSH
# 配置用户名 git config --global user.name "username" # 配置邮箱 git config --global user.email "username@email.com" # 生成 ssh,输完后连敲三个回车即可 ssh-keygen -t rsa
这时候去查看系统盘用户目录下(一般在 C:\Users\你的用户名\.ssh
)是否有了 .ssh 文件夹,进入会看到之前生成的 id_rsa 以及 id_rsa.pub
连接 GitHub
这里不一定是 GitHub,根据各位同学的实际情况来连接不同的服务器,比如 OSChina 的 码云。
下面以 GitHub 为例
在 settings 页面的 SSH and GPG keys 栏中添加,Title 可以自定义,Key 的内容即为之前生成的 id_rsa.pub 文件内容(复制进来即可)
打开 git bash 窗口
$ ssh git@github.com PTY allocation request failed on channel 0 Hi stephencode! You've successfully authenticated, but GitHub does not provide shell access. Connection to github.com closed.
OK,已经成功能连上 GitHub了
在 Sublime Text 3 上安装 Git 插件
这里我假定 Sublime Text 3 已经安装了 Package Control,并且假定也会如何通过该插件来安装其他插件了。
打开 Package Control 后搜索 git 回车即可,安装完成后打开菜单栏 Preferences/Package Settings/Git/Settings - User
输入如下代码并保存
{ "git_command": "git安装目录\\Git\\cmd\\git.exe" }
至此,Git 环境已搭建的差不多了
实战
场景描述
某日看到同学 Github 上维护了一个不错的开源项目(test),想要加入一起为该项目做贡献。刚好发现该项目还没有添加 README.md,因此要将其代码拷贝到本地并在本地新建 README.md,最后更新到远程仓库(简单起见,不考虑分支)
克隆项目至本地
访问项目 test 主页面,复制其 ssh 地址
在本地 git bash 窗口
git clone git@github.com:stephencode/test.git 你的下载目录
新建并提交
用 Sublime Text 3 打开该项目,新建 README.md 在项目根目录
Ctrl + Shift + P 调起命令面板,输入 ga,选择 Git::Add Current File,将 README.md 文件提交至暂存区
Ctrl + Shift + P 调起命令面板,输入 gc,选择 Git::Commit,将 README.md 文件提交至版本库,这时会弹出提交日志的文件,首行输入此次更新的内容和目的,关闭该文件即可
Ctrl Shift P Bring up the command panel, enter gp, select Git::Push, and change README.md The file is submitted to the remote repository, and you can also see in the background panel that it has been successfully synchronized to the remote repository
Recommended tutorial: Sublime Text tutorial
The above is the detailed content of How to install and build a Git environment for Sublime Text3. For more information, please follow other related articles on the PHP Chinese website!

SublimeText is suitable for users who pursue speed and simplicity, while VSCode is suitable for users who need rich features and powerful integration capabilities. 1) SublimeText is known for its lightweight and highly customizable, fast and powerful multi-line editing. 2) VSCode is known for its scalability and integration, with built-in Git support and debugging tools, suitable for cross-language development.

SublimeTextexcelsinspeedandsimplicity,idealforquickeditsandadistraction-freeenvironment,whileVSCodeoffersextensivefeaturesandcustomizationforlargerprojects.SublimeTextislightweightandfast,perfectforfocusedcodingwithasimplecommandpaletteforactionslike

SublimeText is suitable for programming because it is powerful and flexible. 1) Multiple selection and editing functions allow multiple locations to be modified at the same time to improve reconstruction efficiency. 2) The command panel and shortcut keys provide quick access and custom operations to improve development efficiency. 3) Support regular expressions, macros and plug-ins, suitable for advanced usage and performance optimization.

SublimeText is available for purchase for one time, priced at $70, and is permanently used with a PC; VSCode is free to use, and there is no license fee, but extensions and themes may be charged. When choosing, use requirements and budgets should be considered.

To run Sublime Text, you need to download, install the application, purchase a license (optional), and then launch the application. Create or open a file to start encoding.

Sublime Text can be Chineseized through the following steps: 1. Download the Chinese package; 2. Install the Chinese package; 3. Restart Sublime Text; 4. Set the default language (optional); 5. Verify the Chinese version.

There are two ways to delete plugins in Sublime Text: Delete through the Plug-in Manager: Select the plug-in you want to delete and right-click and select "Delete". Manually Delete: Navigate to the user data directory, locate the plugin folder and drag it to the Recycle Bin or Trash.

To write code using GBK encoding in Sublime Text, you need to: 1. Set the project encoding to GBK; 2. Create a new file; 3. Select GBK encoding when saving as; 4. Enter the code using GBK encoding.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 English version
Recommended: Win version, supports code prompts!

SublimeText3 Chinese version
Chinese version, very easy to use

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software