aini 发表于 2018-1-14 11:00:17

学会Git玩转Github笔记(二)

  一、Git基本工作流程

Git工作区域
  https://images2015.cnblogs.com/blog/1001990/201704/1001990-20170407175735097-1915194782.png

向仓库中添加文件流程
https://images2015.cnblogs.com/blog/1001990/201704/1001990-20170407175747738-1210235353.png
  二、 Git初始化及仓库创建和操作

基本信息设置
  

1. 设置用户名  
git config
--global user.name 'itcastphpgit1'  

  
2. 设置用户名邮箱
  
git config --global user.email '12345678@qq.com'
  

  脚下留心:该设置在github仓库主页显示谁提交了该文件

初始化一个新的Git仓库
  1、创建文件夹
https://images2015.cnblogs.com/blog/1001990/201704/1001990-20170407175924347-410497360.png
  2、在文件内初始化git(创建git仓库)
  

cd test    #进入项目文件夹  
git init   #初始化
  

https://images2015.cnblogs.com/blog/1001990/201704/1001990-20170407180056425-728448651.png

向仓库添加文件
  

touch a1.php                         # 创建a1.php文件到工作目录  
git add a1.php                      # 添加a1.php到暂存区
  
git commit
-m'第一次提交文件'   # 添加a1.php到仓库  

https://images2015.cnblogs.com/blog/1001990/201704/1001990-20170407180250144-2053701358.png
https://images2015.cnblogs.com/blog/1001990/201704/1001990-20170407180315050-2044640050.png
https://images2015.cnblogs.com/blog/1001990/201704/1001990-20170407180339675-1718183965.png

修改仓库文件
https://images2015.cnblogs.com/blog/1001990/201704/1001990-20170407180424535-1953926040.png
https://images2015.cnblogs.com/blog/1001990/201704/1001990-20170407180452097-103805762.png
https://images2015.cnblogs.com/blog/1001990/201704/1001990-20170407180504207-470963065.png

删除仓库文件
https://images2015.cnblogs.com/blog/1001990/201704/1001990-20170407180546425-1003212548.png

三、Git管理远程仓库

使用远程仓库的目的
  作用:备份,实现代码共享集中化管理
https://images2015.cnblogs.com/blog/1001990/201704/1001990-20170407181051097-2027551588.png
https://images2015.cnblogs.com/blog/1001990/201704/1001990-20170407181100503-762886021.png

Git克隆操作

目的
  将远程仓库(github对应的项目)复制到本地

代码
  git clone 仓库地址
https://images2015.cnblogs.com/blog/1001990/201704/1001990-20170407181139644-72025730.png
  多学一招:仓库地址由来
https://images2015.cnblogs.com/blog/1001990/201704/1001990-20170407181153457-1897931078.png

将本地仓库同步到git远程仓库中
  git push
https://images2015.cnblogs.com/blog/1001990/201704/1001990-20170407181235503-472906615.png
  ︴思考:为什么无法同步,或没有权限 ?
  The requested URL returned error: 403 Forbidden while accessing
https://images2015.cnblogs.com/blog/1001990/201704/1001990-20170407181419425-565918922.png
页: [1]
查看完整版本: 学会Git玩转Github笔记(二)