search
HomeDevelopment ToolssublimeHow to install and build a Git environment for Sublime Text3

How to install and build a Git environment for Sublime Text3

本文主要介绍如何在 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 文件内容(复制进来即可)

How to install and build a Git environment for Sublime Text3

打开 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 地址

How to install and build a Git environment for Sublime Text3

在本地 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 文件提交至暂存区

How to install and build a Git environment for Sublime Text3

Ctrl + Shift + P 调起命令面板,输入 gc,选择 Git::Commit,将 README.md 文件提交至版本库,这时会弹出提交日志的文件,首行输入此次更新的内容和目的,关闭该文件即可

How to install and build a Git environment for Sublime Text3

How to install and build a Git environment for Sublime Text3

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

How to install and build a Git environment for Sublime Text3

How to install and build a Git environment for Sublime Text3

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!

Statement
This article is reproduced at:segmentfault. If there is any infringement, please contact admin@php.cn delete
Sublime Text vs. VS Code: Features and FunctionalitySublime Text vs. VS Code: Features and FunctionalityMay 11, 2025 am 12:20 AM

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.

Sublime Text: The Power of Plugins and PackagesSublime Text: The Power of Plugins and PackagesMay 10, 2025 am 12:17 AM

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.

Is Sublime Text Free? Understanding the LicensingIs Sublime Text Free? Understanding the LicensingMay 09, 2025 am 12:10 AM

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

Sublime Text: Enhancing Your Coding WorkflowSublime Text: Enhancing Your Coding WorkflowMay 08, 2025 am 12:19 AM

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.

Sublime Text: Free to Try, Not Necessarily Free to OwnSublime Text: Free to Try, Not Necessarily Free to OwnMay 07, 2025 am 12:02 AM

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.

Sublime Text: Comparing Paid and Unpaid FeaturesSublime Text: Comparing Paid and Unpaid FeaturesMay 06, 2025 am 12:07 AM

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

Sublime Text: The Cost of a Powerful EditorSublime Text: The Cost of a Powerful EditorMay 05, 2025 am 12:04 AM

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.

Sublime Text: Code Completion, Syntax Highlighting, and MoreSublime Text: Code Completion, Syntax Highlighting, and MoreMay 04, 2025 am 12:04 AM

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.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Article

Hot Tools

DVWA

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

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools