windows下git使用

一、 下载及安装

下载  git2.14.1 64bit

https://git-for-windows.github.io/(官网下载不动)

http://download.csdn.net/download/tang9018/9934317 (下载快)

https://git-scm.com/book/zh/v1 (说明文档)

安装
    next 下一步
    设置目录
    勾选需要的项:
        Additional icons是关于图标的设置
        In the Quick Launch是快速启动图标
        On the Desktop是桌面快捷方式
        Windows Explorer integration是资源管理器集成(右键菜单)
            Git Bash Here是在当前目录运行Git命令行
            Git GUI Here是在当前目录运行Git原生界面
        ssociate .git* configuration files with the default text editor是将所有.git开头的文件使用默认文本编辑器打开
        Associate .sh files to be run with Bash是将所有扩展名为.sh的文件使用Git命令行执行
        Use a TrueType font in all console windows是在所有命令行(包括Windows系统cmd命令行窗口)中都使用TrueType字体
    是否创建在开始菜单中? Don‘t create... 不创建。
    环境设置
        Use Git from Git Bash only不会修改系统环境变量,但是Windows系统cmd命令行中无法使用git命令
        Use Git from the Windows Command Prompt会将git相关程序加入系统环境变量中,使得Windows系统cmd命令行中可以使用git命令
        Use Git and optional Unix tools from the Windows Command - Prompt会将git相关程序以及一些其他的Unix工具加入系统环境变量,使得Windows系统cmd命令行中可以使用git以及Unix工具
    选择库
        use the openssl library 使用OpenSSL库
        use the native windows secure channel library 使用本机Windows安全通道库
    转行规则
        Checkout Windows-style, commit Unix-style line - endings选项让Git能够自动转换文件中的换行符;签出到本地时转换为Windows下的换行符,提交到服务器时转换为Unix下的换行符
        Checkout as-is, commit Unix-style line endings选项让Git在签出到本地时不做转换,保留原始文件的换行符;提交到服务器时转换为Unix下的换行符
        Checkout as-is, commit as-is让Git在签出到本地时和提交到服务器时都不做转换
    使用控制台程序
        Use MinTTY (the default terminal of MSys2) 选项使用一款叫做MinTTY的软件作为Git命令行,MinTTY是一款模拟Unix系Bash终端的软件。优点是命令记录、可配置字体、可改变窗口大小等等,缺点是可能无法直接运行原Windows下的一些命令行程序
        Use Windows‘ default console windows选项使用Windows系统cmd命令行来作为Git命令行。优点和缺点正好和上一个选项相反。
    其他选项
        Enable file system chaching 启用文件缓存
        Enable Git Credential Manager 启用凭据管理
        Enable symbolic links 启用符号链接
    等待安装进度。
        Launch git Bash 现在启动
        View release notes 查看发行说明
    等待安装完成后,在CMD命令中输入git或者git --version命令查看是否安装成功。

二、简单配置git

1、设置邮箱和地址

第一个要配置的是你个人的用户名称和电子邮件地址。这两条配置很重要,每次 Git 提交时都会引用这两条信息,说明是谁提交了更新,所以会随更新内容一起被永久纳入历史记录:

$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com

如果用了 --global 选项,那么更改的配置文件就是位于你用户主目录下的那个,以后你所有的项目都会默认使用这里配置的用户信息。如果要在某个特定的项目中使用其他名字或者电邮,只要去掉 --global 选项重新配置即可,新的设定保存在当前项目的 .git/config 文件里。

2、提高命令输出可读性

$ git config --global color.ui auto

3、查看配置信息

git config --list

三、使用git提交到GitHub

1.注册GitHub

https://github.com/

2.本地获得SSH Key

git中输入

ssh-keygen -t rsa -C "邮箱地址"

回车、输入密码、确认密码

 C盘/用户名/.ssh 下会生成两个文件

id_rsa文件是私有密钥,id_rsa.pub是公有密钥

3.在github中添加公有密钥

 

把本地生成的密钥输入进 NEW SSH KEY

4.在github创建仓库

创建仓库成功后获得SSH

5.获得仓库数据

在本地指定路径右键

输入

git clone git@github.com:buchizaodian/python.git

 

成功下载到本地

 

6.推送到GitHub

通过Add 命令将文件加入暂存区

git add abc.txt

commit 提交( “”里是描述)

git commit -m "abc"

git log 查看日志

git log

git push 立即推送到服务器

git push
原文地址:https://www.cnblogs.com/buchizaodian/p/7535399.html