Git使用

安装 :  # yum  install git

使用 Git 来获取 Git 的升级:# git clone git://git.kernel.org/pub/scm/git/git.git

初次运行 Git 前的配置

用户信息设置

[root@localhost ~]# git config --global user.name "dxtrp"   # 设置用户名
[root@localhost ~]# git config --global user.email "ttrrpp@gmail.com"   #  设置电子邮件
[root@localhost ~]# git config --global user.email   # 确认在 Git 中正确设置了电子邮件地址
ttrrpp@gmail.com

[root@localhost ~]# git config --global core.editor vim  # 设置编辑器
[root@localhost ~]# git config --global core.editor  # 检查设置的编辑器
vim

检查配置信息

[root@localhost ~]# git config --list
user.name=dxtrp
user.email=ttrrpp@gmail.com
core.editor=vim

获取帮助

$ git help <verb>
$ git <verb> --help
$ man git-<verb>

Git 基础

能够配置并初始化一个仓库(repository)、开始或停止跟踪(track)文件、暂存(stage)或提交(commit)更改。

如何配置 Git 来忽略指定的文件和文件模式、如何迅速而简单地撤销错误操作、如何浏览项目的历史版本以及不同提交(commits)间的差异、如何向远程仓库推送(push)以及如何从远程仓库拉取(pull)文件。

- 获取 Git 仓库

有两种取得 Git 项目仓库的方法。 第一种是在现有项目或目录下导入所有文件到 Git 中; 第二种是从一个服务器克隆一个现有的 Git 仓库。

在现有目录中初始化仓库

[root@localhost ~]# git init
已初始化空的 Git 仓库于 /root/.git/

克隆仓库的命令格式是 git clone [url] 。 比如,要克隆 Git 的可链接库 libgit2,可以用下面的命令:

$ git clone https://github.com/libgit2/libgit2

原文地址:https://www.cnblogs.com/ttrrpp/p/12173404.html