本文主要介绍如何在 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 developers who pursue speed and simplicity, while VSCode is suitable for users who need strong scalability and integration capabilities. 1.SublimeText is known for its lightweight and fast response, with GotoAnything and multi-select powerful. 2. VSCode is known for its scalability and IDE functions, with built-in Git and debugging tools, and IntelliSense improves development efficiency.

SublimeText's plug-ins and packages can be installed and managed through PackageControl to improve programming efficiency. 1. Install plug-ins such as BracketHighlighter to simplify code reading by highlighting bracket matching. 2. Use SublimeLinter to configure pylint to implement real-time code checking. 3. Use SideBarEnhancements to customize the sidebar function to optimize file management.

SublimeTextisfreeduringanunlimitedtrial,buta$99licenseisrecommendedforregularuse.1)Thetrialallowsfullfeatureaccesswithouttimelimits.2)Alicenseoffersperpetualuse,futureupdates,andremovespurchasereminders,enhancingproductivityandsupportingdevelopers.

SublimeText can greatly improve work efficiency. 1) Multiple selection and multicursor functions allow editing of multiple positions at the same time, 2) Command panel provides fast function access, 3) Macros and fragments can automate common operations, 4) Optimized configuration and shortcut key use can improve performance and efficiency.

SublimeText offers a free trial, but ultimately requires a paid purchase for a permanent authorization. 1) During the free trial period, users can experience its functions, but they will receive a purchase prompt. 2) After purchase, users can use it permanently, no subscription fee, and access more plug-ins and themes.

ThemaindifferencesbetweenthepaidandunpaidversionsofSublimeTextaretheremovalofstatusbarremindersandoccasionalpop-uppromptsinthepaidversion.1)Unregisteredversion:fullyfunctionalwithallcorefeatureslikesyntaxhighlighting,codecompletion,andcommandpalette,

SublimeText is worth buying. 1) Its simple interface and powerful functions, such as multi-line editing and GotoAnything, improve development efficiency. 2) Rich plug-in ecosystem, such as Anaconda, enhances the development experience. 3) Although the price is $70, its performance and fluency are great value for professional developers.

SublimeText is loved by developers for its powerful code completion and syntax highlighting capabilities. 1) Code completion can automatically prompt function names, variable names, etc. to improve programming efficiency. 2) Syntax highlighting distinguishes code elements through different colors to improve readability and error detection speed.


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

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

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Zend Studio 13.0.1
Powerful PHP integrated development environment

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

Dreamweaver Mac version
Visual web development tools
