初识git和git安装

目录

版本管理

git安装

1下载git安装包

2 运行下载的安装包

3 阅读基本信息,点击next进入下一步操作

4 选择你要安装的目录,然后next进入下一步

5 所有必要组件都已默认勾选,用默认的选项即可,点击next进入下一步

6 创建开始菜单目录,用默认的即可

7 选择默认编辑器.默认为vim,选默认的即可

8 配置PATH环境,选择默认的(或者Use Git from Git Bash only )即可下一步

9 选择HTTPS传输后端,选择默认的即可

10 换行符的处理,选择默认的即可

11 配置终端模拟器以与 Git Bash 一起使用,选择默认的即可

12 配置额外的选项,选择默认的即可

13 点击install安装

安装完毕,进行用户名、邮箱初始化设置


版本管理

版本管理就是管理更新的历史记录.分为集中型(以Subversion为代表)和分散型(以git为代表),后面的集中型都是以subversion为例子,分散型指以Git为例子.

集中型将所有数据集中存放在服务器当中,有便于管理的优点。但是一旦开发者所处的环境不能连接服务器,就无法获取最新的源代码,开发也就几乎无法进行。服务器宕机时也是同样的道理,而且万一服务器故障导致数据消失,恐怕开发者就再也见不到最新的源代码了。集中型管理图例所示:

分散型GIT用来托管代码的,主要有GitHub码云两个平台。分散型基本流程图如下

 Fork 就是将 GitHub 的某个特定仓库复制到自己的账户下。 Fork 出的仓库与原仓库是两个不同的仓库,开发者可以随意编辑。

所有仓库之间都可以进行push 和 pull。即便不通过 GitHub,开发者 A 也可以直接向开发者 B 的仓库进行 push 或 pull。

git安装

1下载git安装包

官网地址:https://gitforwindows.org/

2 运行下载的安装包

3 阅读基本信息,点击next进入下一步操作

4 选择你要安装的目录,然后next进入下一步

5 所有必要组件都已默认勾选,用默认的选项即可,点击next进入下一步

Additional icons    附加图标

On the Desktop    在桌面上

Windows Explorer integration    Windows资源管理器集成(出现在鼠标右键菜单栏)

Git LFS (Large File Support)    大文件支持

Associate .git* configuration files with the default text editor    将 .git 配置文件与默认文本编辑器相关联

Associate .sh files to be run with Bash    将.sh文件关联到Bash运行

Use a TrueType font in all console windows    在所有控制台窗口中使用TrueType字体

Check daily for Git for Windows updates    每天检查Git是否有Windows更新

6 创建开始菜单目录,用默认的即可

7 选择默认编辑器.默认为vim,选默认的即可

8 配置PATH环境,选择默认的(或者Use Git from Git Bash only )即可下一步

Use Git from Git Bash only  仅使用Git Bash的Git

This is the safest choice as your PATH will not be modified at all.You will only be able to use the Git command line tools form Git Bash

这是最安全的选择,因为您的PATH根本不会被修改。您只能使用 Git Bash 的 Git 命令行工具。

Use Git from the Windows Command Prompt    从Windows命令提示符使用Git

This option is considered safe as it only adds some minimal Git wrappers to your PATH to avoid cluttering your environment with optional Unix tools . You will be able to use Git from both Git Bash and the Windows Command Prompt.

这个选项被认为是安全的,因为它只向PATH添加一些最小的 Git包,以避免使用可选的Unix工具混淆环境。 您将能够从 Git Bash 和 Windows 命令提示符中使用 Git。

Use Git and optional Unix tools from the Windows Command Prompt  使用Windows命令提示符中的Git和可选UNIX工具

Both Git and the optional Unix tools will be added to you PATH   

Git和可选的Unix工具都将添加到您计算机的 PATH 中

Warning:This will override Windows tools like "find and sort".Only use this option if you understand the implications.

警告:这将覆盖Windows工具,如 “ find 和 sort ”。只有在了解其含义后才使用此选项。

9 选择HTTPS传输后端,选择默认的即可

Use the OpenSSL library

使用 OpenSSL 库

Server certificates will be validated using the ca-bundle.crt file.

服务器证书将使用ca-bundle.crt文件进行验证。

Use the native Windows Secure Channel library

使用本地 Windows 安全通道库

Server certificates will be validated using Windows Certificate Stores.This option also allows you to use your company's internal Root CA certificates distributed e.g. via Active Directory Domain Services.

服务器证书将使用Windows证书存储验证。此选项还允许您使用公司的内部根CA证书,例如, 通过Active Directory Domain Services 。

10 换行符的处理,选择默认的即可

Mac 或 Linux 中的 LF(Line Feed)换行。然而,由于 Windows 中是以CRLF(Carriage Return +Line Feed)换行的,所以在非对应的编辑器中将不能正常显示。Git 可以通过设置自动转换这些换行符。使用 Windows 环境的各位,请选择推荐的“Checkout Windows-style, commit Unix-style line endings”选项。换行符在签出时会自动转换为 CRLF,在提交时则会自动转换为LF。

Git will convert LF to CRLF when checking out text files.When committing text files,CRLF will be converted to LF .For cross-pltform projects,this is the recommended setting on Windows ("core.autocrlf" is set to "true")

在检出文本文件时,Git会将LF转换为CRLF。当提交文本文件时,CRLF将转换为LF。 对于跨平台项目,这是Windows上推荐的设置(“core.autocrlf”设置为“true”)

Git will not perform any conversion when checking out text files. When committing text files, CRLF will be converted to LF. For cross-platform projects,this is the recommended setting on Unix ("core.autocrlf" is set to "input")
在检出文本文件时,Git不会执行任何转换。 提交文本文件时,CRLF将转换为LF。 对于跨平台项目,这是Unix上的推荐设置 (“core.autocrlf”设置为“input”)

Git will not perform any conversions when checking out or committing text files.Choosing this option is not recommended for cross-platform projects ("core.autocrlf"is set to "false")

在检出或提交文本文件时,Git不会执行任何转换。对于跨平台项目,不推荐使用此选项(“core.autocrlf”设置为“false”)

11 配置终端模拟器以与 Git Bash 一起使用,选择默认的即可

Git Bash will use MinTTY as terminal emulator,which sports a resizable window,non-rectangular selections and a Unicode font. Windows console programs (such as interactive Python) must be launched via 'winpty' to work in MinTTY.

Git Bash将使用MinTTY作为终端模拟器,该模拟器具有可调整大小的窗口,非矩形选区和Unicode字体。Windows控制台程序(如交互式Python)必须通过'winpty'启动才能在MinTTY中运行。

Git will use the default console window of Windows ("cmd.exe"),which works well with Win32 console programs such as interactive Python or node.js , but has a very limited default scroll-back,needs to be configured to use aUnicode font in order to display non-ASCII characters correctly,and prior to Windows 10 its windows was not freely resizable and it only allowed rectangular text selections.

Git将使用Windows的默认控制台窗口(“cmd.exe”),该窗口可以与Win32控制台程序(如交互式Python或node.js)一起使用,但默认的回滚非常有限,需要配置为使用unicode 字体以正确显示非ASCII字符,并且在Windows 10之前,其窗口不能自由调整大小,并且只允许矩形文本选择。

12 配置额外的选项,选择默认的即可

Enable file system caching
启用文件系统缓存

File system data will be read in bulk and cached in memory for certain operations ("core.fscache" is set to "true"). This provides a significant performance boost.
文件系统数据将被批量读取并缓存在内存中用于某些操作(“core.fscache”设置为“true”)。 这提供了显着的性能提升。

 
Enable Git Credential Manager
启用Git凭证管理器

The Git Credential Manager for Windows provides secure Git credential storage for Windows,most notably multi-factor authentication support for Visual Studio Team Services and GitHub. (requires .NET framework v4.5.1 or or later).
Windows的Git凭证管理器为Windows提供安全的Git凭证存储,最显着的是对Visual Studio Team Services和GitHub的多因素身份验证支持。 (需要.NET Framework v4.5.1或更高版本)。

Enable symbolic links
启用符号链接

Enable symbolic links (requires the SeCreateSymbolicLink permission).Please note that existing repositories are unaffected by this setting.
启用符号链接(需要SeCreateSymbolicLink权限)。请注意,现有存储库不受此设置的影响。

13 点击install安装

 

安装完成点击Finish

安装完毕,进行用户名、邮箱初始化设置

设置姓名和邮箱地址
git config --global user.name "用户名"

git config --global user.email "邮箱"

这个名字和邮箱可以自己随意填写,不必是GitHub或者码云上面的用户名和邮箱.这里设置的姓名和邮箱地址会用在 Git 的提交日志中。由于在 GitHub (或者码云)上公开仓库时,这里的姓名和邮箱地址也会随着提交日志一同被公开,所以请不要使用不便公开的隐私信息。可以通过命令vim ~/.gitconfig查看当前的用户信息,如下图

设置用户名和邮箱之后也可以通过相同的命令修改.修改全局的命令为

git config  --global user.name "用户名";

git config  --global user.email "邮箱";

也可以在vim ~/.gitconfig命令进入的界面修改保存退出即可.

当然,也可以单独修改当前项目的用户名和邮箱

git config user.name "用户名";

git config user.email "邮箱";

提高命令输出的可读性,让代码高亮显示

$ git config --global color.ui auto

"~/.gitconfig"中会增加下面一行。

里面很多内容摘自《GitHub入门与实践》

git官方中文文档:https://git-scm.com/book/zh/v2

码云git大全:https://gitee.com/all-about-git

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值