Git使用教程之初级入门命令行(二)
时间:2019-08-24
本文章向大家介绍Git使用教程之初级入门命令行(二),主要包括Git使用教程之初级入门命令行(二)使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
一、Git 操作流程图
1.git --help 查看帮助
Administrator@PC-xiaobing MINGW64 /d/Git (master) $ git --help usage: git [--version] [--help] [-C <path>] [-c name=value] [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path] [-p | --paginate | --no-pager] [--no-replace-objects] [--bare] [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>] <command> [<args>] These are common Git commands used in various situations: start a working area (see also: git help tutorial) clone Clone a repository into a new directory init Create an empty Git repository or reinitialize an existing one work on the current change (see also: git help everyday) add Add file contents to the index mv Move or rename a file, a directory, or a symlink reset Reset current HEAD to the specified state rm Remove files from the working tree and from the index examine the history and state (see also: git help revisions) bisect Use binary search to find the commit that introduced a bug grep Print lines matching a pattern log Show commit logs show Show various types of objects status Show the working tree status grow, mark and tweak your common history branch List, create, or delete branches checkout Switch branches or restore working tree files commit Record changes to the repository diff Show changes between commits, commit and working tree, etc merge Join two or more development histories together rebase Reapply commits on top of another base tip tag Create, list, delete or verify a tag object signed with GPG collaborate (see also: git help workflows) fetch Download objects and refs from another repository pull Fetch from and integrate with another repository or a local branch push Update remote refs along with associated objects 'git help -a' and 'git help -g' list available subcommands and some concept guides. See 'git help <command>' or 'git help <concept>' to read about a specific subcommand or concept.
2.git基础操作
Administrator@PC-xiaobing MINGW64 /d $ cd D:/Git/ //cd到指定文件 Administrator@PC-xiaobing MINGW64 /d/Git $ pwd //查看当前文件目录 /d/Git Administrator@PC-xiaobing MINGW64 /d/Git $ git init //初始化本地git仓库 Initialized empty Git repository in D:/Git/.git/ Administrator@PC-xiaobing MINGW64 /d/Git (master) $ git add test.txt //从工作区添加本地文件test.txt到暂存区 Administrator@PC-xiaobing MINGW64 /d/Git (master) $ git commit -m "test" //从暂存区commit提交到本地仓库 //第一次安装Git提交commit的时候提示设置name和邮箱 *** Please tell me who you are. Run git config //global user.email "you@example.com" git config //global user.name "Your Name" Administrator@PC-xiaobing MINGW64 /d/Git (master) $ git config //global user.name "xiaobing" //根据提示设置name Administrator@PC-xiaobing MINGW64 /d/Git (master) $ git config //global user.email "you@example.com" //根据提示设置邮箱 Administrator@PC-xiaobing MINGW64 /d/Git (master) $ git commit -m "test" //从暂存区commit提交到本地仓库 [master (root-commit) 9bc4419] test 1 file changed, 1 insertion(+) create mode 100644 test.txt //接下来从本地仓库push到远程仓库
3.创建远程仓库GitHub或者GitLib
4.提交变更
git remote add origin https://github.com/xbtest/Demo01.git //git remote 用于管理远程仓库 git push -u origin master //往名字为origin的仓库的master分支上提交变更的代码
Administrator@PC-xiaobing MINGW64 /d/eclipse-workspace/Demo01 (master) $ git remote add origin https://github.com/xbtest/Demo01.git //添加失败 fatal: remote origin already exists. $ git remote rm origin //执行rm删除后再次添加 $ git remote add origin https://github.com/xbtest/Demo01.git
第一次提交代码的时候提示登录
报错:
Administrator@PC-xiaobing MINGW64 /d/Git (master) $ git push -u origin master fatal: HttpRequestException encountered. ▒▒▒▒▒▒▒▒ʱ▒▒▒▒ Username for 'https://github.com': xbtest Everything up-to-date Branch master set up to track remote branch master from origin.
这时候需要 更新Windows的git凭证管理器
点击下载安装 GCMW-1.14.0.exe
下载链接
https://github.com/Microsoft/Git-Credential-Manager-for-Windows/releases/tag/v1.14.0
下载后双击安装即可,再次提交成功:
Administrator@PC-xiaobing MINGW64 /d/Git (master) $ git push -u origin master Everything up-to-date Branch master set up to track remote branch master from origin.
5.验证查看
6.待续....
原文地址:https://www.cnblogs.com/xiaozhaoboke/p/11404038.html
- 运维中的日志切割操作梳理(Logrotate/python/shell脚本实现)
- 线上图片批量更换脚本记录
- memcached程序端口监控脚本
- mysql操作命令梳理(5)-执行sql语句查询即mysql状态说明
- 【7】AccessDB快速数据访问
- 4.微信支付
- 【8】数据浏览表格的快速输出
- Silverlight的自定义tooltip提示工具条
- WritableBitmapEx 一瞥
- 2.认证小程序
- 【9】分页浏览的管理
- 温故而知新:silverlight中的图片资源绑定
- 页面状态保持机制(编辑中)
- mysql主从同步(5)-同步延迟状态考量(seconds_behind_master和pt-heartbea)
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- 为什么要用TypeScript
- np.clip截取函数
- 常见编程模式之双指针
- python操作txt文件中数据教程[2]-python提取txt文件中的行列元素
- JSON 是什么?它能带来什么?它和 XML 比较?
- 一起来学演化计算-实数空间变异算子
- 卡特兰数入门
- 常见编程模式之动态规划:0-1背包问题
- stat 命令家族(2)- 详解 pidstat
- MTO和MaTO MMZDT
- stat 命令家族(3)- 详解 mpstat
- 知识图谱入门(一)
- PHP判断变量内容是什么编码(gbk?utf-8) mb_detect_encoding
- stat 命令家族(4)- 详解 iostat
- PHP将数组存入数据库中的四种方式