码迷,mamicode.com
首页 > 其他好文 > 详细

Git使用教程之初级入门命令行(二)

时间:2019-08-24 23:07:38      阅读:108      评论:0      收藏:0      [点我收藏+]

标签:directory   grep   tree   报错   ranch   signed   files   邮箱   工作区   

一、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.待续....

 

Git使用教程之初级入门命令行(二)

标签:directory   grep   tree   报错   ranch   signed   files   邮箱   工作区   

原文地址:https://www.cnblogs.com/xiaozhaoboke/p/11404038.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!