美文网首页
git 学习

git 学习

作者: 小菜_charry | 来源:发表于2017-08-16 11:38 被阅读13次
  1. download address:

2.open Git Bash and input 'git' you will see all operation:

$ git
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.
  1. initalized a repository use 'git init'
$ git init
Initialized empty Git repository in E:/xiaocai/code/git_test/.git/

4.create some directory and file , then see the status using 'git status'

mkdir test ==> cd test ==> touch a.md ==> vim a.md ==> input some word
---
$ git status
On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        test/

nothing added to commit but untracked files present (use "git add" to track)

it show some change hasnot commit yet

5.using 'git add' to add the change

$ git status
On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        test/

nothing added to commit but untracked files present (use "git add" to track)

CaiRR@YuHeng-PC MINGW64 /e/xiaocai/code/git_test (master)
$ git add test

6.commit the change with "git commit -m 'some message' "

$ git commit -m 'first conmmit'
[master (root-commit) 919a865] first conmmit
 Committer: unknown <CaiRR@ToprankInner.com>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly. Run the
following command and follow the instructions in your editor to edit
your configuration file:

    git config --global --edit

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 1 file changed, 1 insertion(+)
 create mode 100644 test/a.md

CaiRR@YuHeng-PC MINGW64 /e/xiaocai/code/git_test (master)
$ git status
On branch master
nothing to commit, working tree clean

the difference between 'add' and 'commit':

  • ' add ' : just like put it into a temporary space
  • ' commit ' : is put it into repository

7.check the history with 'git log'

$ git log
commit 919a865770adfd83dc4771829c31248b8a583929 (HEAD -> master)
Author: unknown <CaiRR@ToprankInner.com>
Date:   Wed Aug 16 10:39:00 2017 +0800

    first conmmit

8.create a branch with 'git branch xx' or see the branch 'git branch'

$ git branch
* master

CaiRR@YuHeng-PC MINGW64 /e/xiaocai/code/git_test (master)
$ git branch x

CaiRR@YuHeng-PC MINGW64 /e/xiaocai/code/git_test (master)
$ git branch
* master
  x

start with ' * ' mean current using

9.change the branch with 'git checkout x'

CaiRR@YuHeng-PC MINGW64 /e/xiaocai/code/git_test (master)
$ git checkout x
Switched to branch 'x'

CaiRR@YuHeng-PC MINGW64 /e/xiaocai/code/git_test (x)
$ git branch
  master
* x

10.in new branch create some file and commit the merge to 'master' branch

1.create some file and commit
  :touch x.md ==> vim x.md ==> input some word and save ==> git add x.md ==> git commit -m 'some message'

2.change the branch
  $ git checkout master
  Switched to branch 'master'

3.merge the branch
  $ git merge x
  Updating 919a865..0deb1f1
  Fast-forward
   x.md | 1 +
   1 file changed, 1 insertion(+)
   create mode 100644 x.md
  1. delete the unuse branch
$ git branch -d x
Deleted branch x (was 0deb1f1).

CaiRR@YuHeng-PC MINGW64 /e/xiaocai/code/git_test (master)
$ git branch
* master

if you want to delete it force (as no merge to master), using 'git branch -D x'

12.using tag to make a mark,we can change between different tag

1.create tag:
  $ git tag -a v1.0.0 -m 'version 1.0.0'

2.make same change after that tag and create new tag
  touch tag.md ==> vim tag.md ==> git add tag.md ==> git commit -m 'some msg'
  $ git commit -m 'commit after v1.0.0'

3.checkout back to before tag
  $ git checkout v1.0.0

learn more: https://git-scm.com/book/zh/v1/%E8%B5%B7%E6%AD%A5

相关文章

  • Git+node.js+TDD

    目录 Git学习 node.js学习 用Nodejs和Git完成TDD编程 Git学习 Git是什么Git是一款免...

  • Git 学习笔记

    ----------------- Git 学习 ------------------ Git 简介 Git...

  • git 入门

    git 入门学习笔记----3个入门命令:git init、git add、git commit -v 学习场景(...

  • git技术,GitHub、GitLab

    git学习 Git教程(小白快速入门版) Git教程(简化版) git详细学习 Gitlab的管理使用手册git初...

  • Git常用命令与学习总结

    安装Git Git的下载地址:Git官网下载地址 学习网址 git 学习笔记- Book 在线练习地址 基础常用指...

  • Git学习之思维导图

    Git学习之思维导图 Git学习之思维导图

  • git记录

    Git Magic图解gitgit 学习笔记git游戏(学习)1、消除文档路径中文乱码git config --g...

  • git资源学习

    git资源学习 Git详解之一 Git起步 Git详解之二 Git基础 Git详解之三 Git分支 Git详解之四...

  • Git入门学习资源

    Git入门学习资料 廖雪峰 Git教程 Git官网 Pro Git git 简明指南 github-git-che...

  • 2018-04-18

    git学习小结 关于git init,git add,git commit 用法总结 1.首先配置git 全局配置...

网友评论

      本文标题:git 学习

      本文链接:https://www.haomeiwen.com/subject/tzobrxtx.html