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 "[email protected]"
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