Table of Contents
配置全局参数
连接 GitHub
场景描述
克隆项目至本地
新建并提交
Home Development Tools sublime How to install and build a Git environment for Sublime Text3

How to install and build a Git environment for Sublime Text3

Jun 28, 2020 am 10:08 AM
sublime text

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
Copy after login

这时候去查看系统盘用户目录下(一般在 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.
Copy after login

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"
}
Copy after login

至此,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 你的下载目录
Copy after login

新建并提交

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 of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

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 Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Let's talk about how to turn off automatic updates in Sublime (picture and text introduction) Let's talk about how to turn off automatic updates in Sublime (picture and text introduction) Feb 24, 2022 am 10:29 AM

Below, the sublime tutorial column will introduce to you how to turn off automatic updates in Sublime Text. I hope it will be helpful to friends in need!

Development tools and debugging skills for PHP and CGI: improving development efficiency Development tools and debugging skills for PHP and CGI: improving development efficiency Jul 21, 2023 pm 03:12 PM

Development tools and debugging skills for PHP and CGI: Improving development efficiency Summary: PHP and CGI are two commonly used web development languages. In order to improve development efficiency, developers need to master some special development tools and debugging skills. This article will introduce several commonly used PHP and CGI development tools, as well as some debugging techniques to help developers develop and debug more efficiently. 1. Development tool SublimeTextSublimeText is a powerful text editor that supports PHP and C

A brief analysis of the reasons and solutions for why sublime text cannot run php A brief analysis of the reasons and solutions for why sublime text cannot run php Mar 24, 2023 am 10:58 AM

SublimeText is a very popular code editor that is widely used by developers and code writers. In the following article, we will discuss the reasons and solutions for why SublimeText cannot run PHP.

What are the common code editors for PHP programming? What are the common code editors for PHP programming? Jun 12, 2023 pm 12:30 PM

PHP is a popular server-side scripting language that is widely used for web development. In order to write efficient and streamlined PHP code, programmers need to use an excellent code editor. This article will introduce some common code editors in PHP programming. SublimeTextSublimeText is probably one of the most popular code editors. Its flexibility and ease of use make it the editor of choice for many developers. Key features of SublimeText include: High degree of customization

Common PHP editors and development tools Common PHP editors and development tools Jun 23, 2023 am 09:36 AM

In current web development, PHP has become a very popular back-end programming language. However, when developing PHP, choosing high-quality editors and development tools can greatly improve development efficiency and code quality. This article will introduce some common PHP editors and development tools. PHPStormPHPStorm is an integrated development environment (IDE) launched by JetBrains. It provides a series of functions such as powerful PHP development support, code analysis, debugging, and automated testing, and supports

Recommended configuration for C/C++ programming using Sublime Text on Linux Recommended configuration for C/C++ programming using Sublime Text on Linux Jul 04, 2023 pm 05:57 PM

Introduction to the recommended configuration for using SublimeText for C/C++ programming on Linux: SublimeText is a lightweight, powerful and highly customizable text editor. On Linux platforms, using SublimeText for C/C++ programming is a common choice. This article will introduce some recommended configurations and plug-ins to help improve programming efficiency and development experience. Install SublimeText: First, you need to install SublimeText from the SublimeText official website

How to build php in sublime How to build php in sublime Oct 26, 2022 am 09:31 AM

How to build PHP with sublime: 1. Open sublime, click "Ctrl+Shift+P", and then enter install; 2. Configure SublimeLinter; 3. Modify the path; 4. Configure the PHP compilation system; 5. Add "{ "cmd": ["php","$file"],"file_regex": "php$","selector":"source.php"}" is enough.

Sublime Text function for PHP function Sublime Text function for PHP function Mar 27, 2024 am 08:42 AM

PHP is a popular programming language that is widely used to create dynamic websites, applications, and a range of internet technologies. PHP has a large number of built-in functions to help programmers work more efficiently while writing code. If you use SublimeText as your editor, there are some plugins and tricks you can use to make your PHP functions easier to edit and use. In this article, I will introduce some useful SublimeText features that can help you make better use of PHP functions. 1.from

See all articles