• Git使用教程

    • 配置Git
    • 创建仓库
    • 基本用法
    • 三种状态
    • 标签Tag
    • 分支Branch
    • 合并分支
    • 远程仓库
    • 多人远程合作

配置Git

  • git --version  查看Git版本

PS G:\DOC> git --version
git version 2.21.0.windows.1
PS G:\DOC> git config --list  core.symlinks=false  core.autocrlf=true  core.fscache=true  color.diff=auto  color.status=auto  color.branch=auto  color.interactive=true  help.format=html  rebase.autosquash=true  http.sslbackend=openssl  http.sslcainfo=F:/Git/mingw64/ssl/certs/  ca-bundle.crt  credential.helper=manager  user.name=GiottoLee

创建仓库

  • git init   初始化仓库

PS G:\DOC\GitDoc> git init
Reinitialized existing Git repository in G:/DOC/GitDoc/.git/
  • git clone [ 连接 ]   克隆仓库

基本用法

  • git status   查看状态

PS G:\DOC\GitDoc> git status
On branch master
No commits yet
Untracked files:  (use "git add <file>..." to include in what will be committed)  "Git\344\275\277\347\224\250\346\225\231\347\250\213.md"
nothing added to commit but untracked files present (use "git add" to track)
  • git add .  将所有修改添加至暂存区

PS G:\DOC\GitDoc> git add .
  • git add [ File name ]  将指定文件添加至暂存区

PS G:\DOC\GitDoc> git add HowToUseGit.md
  • git commit -m " 备注 "   提交版本

PS G:\DOC\GitDoc> git commit -m "Contribute how to use Git tools."
[master (root-commit) 3ccc1ff] Contribute how to use Git tools.1 file changed, 55 insertions(+)create mode 100644 "Git\344\275\277\347\224\250\346\225\231\347\250\213.md"
  • git log   查看历史版本

PS G:\DOC\GitDoc> git log
commit 3ccc1ff91f3e2a6f9ed5908f414717893d9e3928 (HEAD -> master)
Author: GiottoLee <giottolee@outlook.com>
Date:   Sun Apr 7 21:17:44 2019 +0800Contribute how to use Git tools.
  • git log -p   查看历史版本附加详细信息

PS G:\DOC\GitDoc> git log -p
commit 3ccc1ff91f3e2a6f9ed5908f414717893d9e3928 (HEAD -> master)
Author: GiottoLee <giottolee@outlook.com>
Date:   Sun Apr 7 21:17:44 2019 +0800Contribute how to use Git tools.diff --git "a/Git\344\275\277\347\224\250\346\225\231\347\250\213.md" "b/Git\344\275\277\347\224\250\346\225\231\347\250\213.md"
new file mode 100644
index 0000000..dc41cd9
--- /dev/null
+++ "b/Git\344\275\277\347\224\250\346\225\231\347\250\213.md"
@@ -0,0 +1,55 @@
+# Git使用教程
+
+## **配置Git**
+
+- ### git --version &emsp;查看Git版本
+> PS G:\DOC> git --version
+git version 2.21.0.windows.1
+...+
+- ### git add . &emsp;将所有修改添加至暂存区
\ No newline at end of file
  • git status   查看当前状态

PS G:\DOC\GitDoc> git status
On branch master
Changes not staged for commit:(use "git add <file>..." to update what will be committed)(use "git checkout -- <file>..." to discard changes in working directory)modified:   "Git\344\275\277\347\224\250\346\225\231\347\250\213.md"no changes added to commit (use "git add" and/or "git commit -a")
  • git checkout 版本号   穿越到指定的历史节点

PS G:\DOC\GitDoc> git checkout f921330
  • git checkout -   回到上一个版本节点

PS G:\DOC\GitDoc> git checkout -

三种状态

  1. Modified   修改状态
  2. Staged   暂存状态
  3. Committed   提交状态

标签Tag

  • git tag   查看标签

PS G:\DOC\GitDoc> git tag
NotFinished
  • git tag -a [ 标签名 ] -m “备注”   添加标签

PS G:\DOC\GitDoc> git tag -a NotFinished -m "New content added"
  • git tag -a [ 标签名 ] -m “备注” [ 版本号 ]   添加标签

PS G:\DOC\GitDoc> git tag -a NotFinished -m "New content added" f2165
  • git show [ 标签名 ]   查看某标签的详细信息

PS G:\DOC\GitDoc> git show NotFinished
tag NotFinished
Tagger: GiottoLee <giottolee@outlook.com>
Date:   Sun Apr 7 21:54:26 2019 +0800New content addedcommit 0c308273691037c07875a3e1239670e94d361722 (HEAD -> master, tag: NotFinished)
Author: GiottoLee <giottolee@outlook.com>
Date:   Sun Apr 7 21:53:10 2019 +0800New content added.diff --git "a/Git\344\275\277\347\224\250\346\225\231\347\250\213.md" "b/Git\344\275\277\347\224\250\346\225\231\347\250\213.md"
index dc41cd9..5f97e4b 100644
--- "a/Git\344\275\277\347\224\250\346\225\231\347\250\213.md"
+++ "b/Git\344\275\277\347\224\250\346\225\231\347\250\213.md"
@@ -3,8 +3,10 @@## **配置Git**- ### git --version &emsp;查看Git版本
-> PS G:\DOC> git --version
+```
+PS G:\DOC> git --version  git version 2.21.0.windows.1
+```<br/>@@ -14,7 +16,8 @@ git version 2.21.0.windows.1- ### git comfig --list &emsp; 查看当前所有项目-> PS G:\DOC> git config --list
+```
+PS G:\DOC> git config --list  core.symlinks=falsecore.autocrlf=truecore.fscache=true
@@ -28,14 +31,17 @@ git version 2.21.0.windows.1http.sslcainfo=F:/Git/mingw64/ssl/certs/  ca-bundle.crtcredential.helper=manageruser.name=GiottoLee
+```<br/>## **创建仓库**- ### git init &emsp; 初始化仓库
-> PS G:\DOC\GitDoc> git init
+```
+PS G:\DOC\GitDoc> git init  Reinitialized existing Git repository in G:/DOC/GitDoc/.git/
+```- ### git clone [ *连接* ] &emsp; 克隆仓库@@ -44,12 +50,109 @@ Reinitialized existing Git repository in G:/DOC/GitDoc/.git/## **基本用法**- ### git status &emsp; 查看状态
->PS G:\DOC\GitDoc> git status
+```
+PS G:\DOC\GitDoc> git status  On branch masterNo commits yetUntracked files:(use "git add <file>..." to include in what will be committed)"Git\344\275\277\347\224\250\346\225\231\347\250\213.md"nothing added to commit but untracked files present (use "git add" to track)
+```-- ### git add . &emsp;将所有修改添加至暂存区
\ No newline at end of file
+- ### git add . &emsp;将所有修改添加至暂存区
+```
+PS G:\DOC\GitDoc> git add .
+```
+
+- ### git add [*File name*] &emsp;将指定文件添加至暂存区
+~~~
+PS G:\DOC\GitDoc> git add HowToUseGit.md
+~~~
+
+- ### git commit -m "*备注*" &emsp; 提交版本
+```
+PS G:\DOC\GitDoc> git commit -m "Contribute how to use Git tools."
+[master (root-commit) 3ccc1ff] Contribute how to use Git tools.
+ 1 file changed, 55 insertions(+)
+ create mode 100644 "Git\344\275\277\347\224\250\346\225\231\347\250\213.md"
+```
+
+- ### git log &emsp; 查看历史版本
+```
+PS G:\DOC\GitDoc> git log
+commit 3ccc1ff91f3e2a6f9ed5908f414717893d9e3928 (HEAD -> master)
+Author: GiottoLee <giottolee@outlook.com>
+Date:   Sun Apr 7 21:17:44 2019 +0800
+
+    Contribute how to use Git tools.
+```
+
+- ### git log -p &emsp; 查看历史版本附加详细信息
+~~~
+PS G:\DOC\GitDoc> git log -p
+commit 3ccc1ff91f3e2a6f9ed5908f414717893d9e3928 (HEAD -> master)
+Author: GiottoLee <giottolee@outlook.com>
+Date:   Sun Apr 7 21:17:44 2019 +0800
+
+    Contribute how to use Git tools.
+
+diff --git "a/Git\344\275\277\347\224\250\346\225\231\347\250\213.md" "b/Git\344\275\277\347\224\250\346\225\231\347\250\213.md"
+new file mode 100644
+index 0000000..dc41cd9
+--- /dev/null
++++ "b/Git\344\275\277\347\224\250\346\225\231\347\250\213.md"
+@@ -0,0 +1,55 @@
++# Git使用教程
++
++## **配置Git**
++
++- ### git --version &emsp;查看Git版本
++> PS G:\DOC> git --version
++git version 2.21.0.windows.1
++
+
+...
+
++
++- ### git add . &emsp;将所有修改添加至暂存区
+\ No newline at end of file
+~~~
+
+
+- ### git status &emsp; 查看当前状态
+```
+PS G:\DOC\GitDoc> git status
+On branch master
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+        modified:   "Git\344\275\277\347\224\250\346\225\231\347\250\213.md"
+
+no changes added to commit (use "git add" and/or "git commit -a")
+```
+
+- ### git checkout *版本号* &emsp; 穿越到指定的历史节点
+```
+PS G:\DOC\GitDoc> git checkout f921330
+```
+
+- ### git checkout - &emsp; 回到上一个版本节点
+~~~
+PS G:\DOC\GitDoc> git checkout -
+~~~
+
+<br/>
+
+## **三种状态**
+
+1. Modified &emsp; 修改状态
+2. Staged &emsp; 暂存状态
+3. Committed &emsp; 提交状态
+
+<br/>
+
+## **标签Tag**
+
+- ### git tag -a [*标签名*] -m "*备注*"
\ No newline at end of file
  • git checkout [ 标签名 ]   回退到该标签的版本

PS G:\DOC\GitDoc>git checkout NotFinished

分支Branch

  • git branch [ 分支名 ]   创建分支

PS G:\DOC\GitDoc>git branch SubLine
Switched to branch 'SubLine'
PS G:\DOC\GitDoc>git checkout master
Switched to branch 'master'
  • git log --all --graph   图示全部历史纪录

PS G:\DOC\test> git log --all --graph
* commit 98e9c52b82abd46e83ed7c4d7433520b128e6edb (HEAD)
| Author: GiottoLee <giottolee@outlook.com>
| Date:   Sun Apr 7 22:44:57 2019 +0800
|
|     4
|
| * commit 0e5fb98813a701a105e8d59b56acd23abea93337 (master)
|/  Author: GiottoLee <giottolee@outlook.com>
|   Date:   Sun Apr 7 22:43:13 2019 +0800
|
|       3
|
* commit 9fcf68107bff21f89e61b06962ba93f3ec794129 (subline)
| Author: GiottoLee <giottolee@outlook.com>
| Date:   Sun Apr 7 22:43:03 2019 +0800
|
|     2
|
* commit bdcedd53fe633d870e8c2b708bf3703ae647f7deAuthor: GiottoLee <giottolee@outlook.com>Date:   Sun Apr 7 22:42:43 2019 +0800First commitPS

合并分支

  • git merge [ 分支名 ]   合并分支到当前分支

PS G:\DOC\GitDoc>git merge SubLine
1
2
//****************冲突部分********************
<<<<<<< HEAD
3
=======
fixed
>>>>>>> subline
//********************************************

远程仓库

  • git remote add [ 远程名称 ] [ 远程地址 ]   设置远程仓库

PS G:\DOC\GitDoc> git remote add GitHelpDoc git@github.com:G/GitHelpDoc.git
  • git remote   列出所有远程仓库

PS G:\DOC\GitDoc> git remote
GitHelpDoc
  • git push -u [ 远程名称 ] [ 分支名 ]   上传代码

PS G:\DOC\GitDoc> git push -u GitHelpDoc master
Warning: Permanently added the RSA host key for IP address '52.74.223.119' to the list of known hosts.
Enumerating objects: 6, done.
Counting objects: 100% (6/6), done.
Delta compression using up to 8 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (6/6), 1.97 KiB | 404.00 KiB/s, done.
Total 6 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), done.
To github.com:GiottoLee/GitHelpDoc.git* [new branch]      master -> master
Branch 'master' set up to track remote branch 'master' from 'GitHelpDoc'.
PS G:\DOC\GitDoc>
  • git clone [ 仓库地址 ]   克隆远程仓库

PS G:\DOC\GitDoc> git clone git@github.com:G/GitHelpDoc.git
  • git pull   获取远程更新

PS G:\DOC\GitDoc> git pull

多人远程合作

  • git clone [ 仓库地址 ] [ FileName ]   克隆远程仓库到指定文件夹

PS G:\DOC\GitDoc> git clone git@github.com:G/GitHelpDoc.git newFile

Github文档下载

Git版本控制及远程仓库的使用相关推荐

  1. git 无法 push 远程仓库 【Note about fast-forwards】

    git 无法push远程仓库 Note about fast-forwards 提出问题 基本介绍 解决方案 提出问题 git push 远程仓库时,经常报出如下错误,导致无法将本地仓库中的内容提交到 ...

  2. git 本地与远程仓库出现代码冲突解决方法

    git 本地与远程仓库出现代码冲突解决方法 参考文章: (1)git 本地与远程仓库出现代码冲突解决方法 (2)https://www.cnblogs.com/heaven-xi/p/9703566. ...

  3. 使用git拉取远程仓库代码

    git拉取远程仓库代码 引言: 项目需要在阿里云里面拉取代码,本来以为自己会,结果好几歩都出错了,这里记录一下步骤 下载安装好git,打开Git Bash Here,进行初始化三步. 1.git in ...

  4. git添加/删除远程仓库

    注意:仓库只有管理员建的你才有权限上传,不然自己建的也没用,没权限上传 1.远程仓库路径查询 git remote -v 2.添加远程仓库 git remote add origin <你的项目 ...

  5. Git 本地与远程仓库同步操作

    git fetch 做了些什么 git fetch 完成了仅有的但是很重要的两步: 从远程仓库 下载 本地仓库中缺失的 提交记录 更新远程分支指针(假设为 o/master) git fetch 实际 ...

  6. Git撤销对远程仓库的push 或 Git撤销对远程仓库的commit提交

    Git撤销对远程仓库的push 或 Git撤销对远程仓库的commit提交 [一]撤销push 执行 git log 查看日志,获取需要回退的版本号 执行 git reset –-soft <版 ...

  7. git 拉取远程仓库分支代码

    git 拉取远程仓库分支代码 本地新建文件夹作为工作区(存放代码的文件夹) 进入该文件,右键选择 git bush here,打开命令窗后,输入初始化命令:git init 命令行:git remot ...

  8. 使用git同步到远程仓库

    使用git同步到远程仓库 在仓库所在的目录(D:\temp\git\repository)点击右键选择"Git Bash Here",启动git bash程序. 然后在git ba ...

  9. git连接github远程仓库

    一:设置用户名和邮箱 打开Git Bash Here 输入: git config --global user.name '用户名' git config --global user.email '邮 ...

  10. git版本控制、本地仓库、远程连接等操作分析

    一.Git基本操作 1.1 配置 git是一个分布式版本控制系统,这意味着每个人的电脑上都是一个完整的版本库,我们不再需要将代码上传至"中央服务器上",每个人电脑里都有完整的版本库 ...

最新文章

  1. [摘]终于找到一个有助理解left/right/full outer join的例子
  2. 【Jboss】热部署
  3. 苹果连接电脑只能充电_苹果获得MagSafe式充电技术专利 可自动连接充电
  4. [YTU]_2353 ( 长方柱类【C++ 类定义】)
  5. SVN中检出(check out) 和 导出(export) 的区别
  6. 减少到处衍生的实体类
  7. php更多式样,php_1
  8. Paravirtualization (半虚拟化PV) - Xen
  9. 陆奇、雷军、熊晓鸽聊疫情后的创业风口
  10. flink基本原理入门
  11. 给大家介绍一款相亲交友小程序
  12. 微信公众号笔记(一)
  13. VIVADO软件介绍与使用
  14. 天下难事必作于易,天下大事必作于细
  15. 嵌入式和移动深度学习研究
  16. java web租车系统_JavaWeb在线租车服务系统项目源码(福利)
  17. 百度快照被劫持跳转到博彩网站 终极解决办法
  18. 产品经理眼中的MVP
  19. discuzX 论坛列表页获取帖子内容页主题的pid
  20. 技术分享:铜基板的小孔加工改善研究

热门文章

  1. 线索二叉树算法 - 草根编程网
  2. 程序员应知——我们不是客户
  3. Linux 下串口编程入门教程
  4. Illustrator 教程,如何在 Illustrator 中对矢量图进行变形、定形和塑形?
  5. Illustrator 教程,如何在 Illustrator 中创建和编辑作品?
  6. iOS开发之开源项目链接
  7. 项目任务管理工具Project Office for mac
  8. 如何在 macOS 中批量重命名文件?
  9. 苹果Mac桌面Dock中App icon 名称显示乱码怎么办?一个简单指令帮你解决
  10. Karabiner Elements使用技巧分享,帮您简单修改使用键位