git_安装

1 是什么?

Git是一个免费的开源分布式版本控制系统,旨在快速高效地处理从小型到大型项目的所有事务。

2 安装

进入官网,针对自己的操作系统选择下载  https://git-scm.com/downloads

 

 由于外网下载速度很慢,所以选择找了一个链接下载https://pc.qq.com/detail/13/detail_22693.html

 

 

 

 全部选择下一步,然后单击安装即可。

 

点击鼠标右键,即可看到git的图形界面和命令行两个菜单。

 

2 配置

官网操作手册 https://git-scm.com/docs/git-config 

配置用户名和邮箱

git config --global user.email "you@example.com"
git config --global user.name "Your Name"

3 命令的使用

可查看官方文档 https://git-scm.com/docs/git;用户手册https://git-scm.com/docs/user-manual.html

一般忘记命令,可使用git xx --help或者git help xx来调用文档查看,例如 git add --help,即调出一个链接的页面。

  • 生成工作区   git init
  • 将文件放到暂存区  git add 文件名
  • 提交文件 git commit 文件名
  • 设置远程仓库的别名   git remote add 别名 https://github.com/axuezhonghua/test1.git
  • 提交到远程仓库   git push -u 别名 master   
  • 进行上面操作后第一次会跳出验证窗口进行验证

 

 进入github即可看到我们提交的代码或者文件

 

 在github上直接修改该文件,然后在本地进行更新。

  • git fetch 拉取远程仓库的更新
  • git merge master 合并变更到本地master

 4 客户端

git自带的客户端界面不太好用,则用sourcetree  https://www.sourcetreeapp.com/

由于外网下载太慢选择https://pc.qq.com/search.html#!keyword=sourcetree该链接进行下载

 

 

 

 由于上面一步需要进行账号登录,但是我们又打不开外网,所以需要逃过该步骤

在下面目录下新建一个accounts.json文件

输入以下内容

[
	  {
	    "$id": "1",
	    "$type": "SourceTree.Api.Host.Identity.Model.IdentityAccount, SourceTree.Api.Host.Identity",
	    "Authenticate": true,
	    "HostInstance": {
	      "$id": "2",
	      "$type": "SourceTree.Host.Atlassianaccount.AtlassianAccountInstance, SourceTree.Host.AtlassianAccount",
	      "Host": {
	        "$id": "3",
	        "$type": "SourceTree.Host.Atlassianaccount.AtlassianAccountHost, SourceTree.Host.AtlassianAccount",
	        "Id": "atlassian account"
	      },
	      "BaseUrl": "https://id.atlassian.com/"
	    },
	    "Credentials": {
	      "$id": "4",
	      "$type": "SourceTree.Model.BasicAuthCredentials, SourceTree.Api.Account",
	      "Username": "",
	      "Email": null
	    },
	    "IsDefault": false
	  }
	]

 

 重新点击可执行文件

 

 

 

 

 

 

posted @ 2019-08-31 21:02  S-Mustard  阅读(194)  评论(0编辑  收藏  举报