美文网首页
初识 Git

初识 Git

作者: iMark | 来源:发表于2016-06-14 12:45 被阅读43次

[TOC]

了解 Git


Git is a fast, scalable, distributed revision control system with an unusually rich command set that provides both high-level operations and full access to internals.

那为什么要使用Git呢?

因为他们都在用Git...

其实使用 Git 已经快俩月了,不过用的不多,而且基本上是基于 GitHub 的 windows 客户端操作的。想要真正理解 Git ,其实还是需要从命令行开始。

工欲善其事必先利其器:
git

一个非常有用的 命令: git help everyday

everyday Git with 20 commands or so

其实使用命令行的都知道:
git help

git help
DELL@DELL-PC MINGW64 ~/Desktop
$ 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.

如果在后面带上一个参数 -g 的话。。。


git help -g
DELL@DELL-PC MINGW64 ~/Desktop
$ git help -g
The common Git guides are:

   attributes   Defining attributes per path
   everyday     Everyday Git With 20 Commands Or So
   glossary     A Git glossary
   ignore       Specifies intentionally untracked files to ignore
   modules      Defining submodule properties
   revisions    Specifying revisions and ranges for Git
   tutorial     A tutorial introduction to Git (for version 1.5.1 or newer)
   workflows    An overview of recommended workflows with Git

'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.

先看看这些基本的命令吧,真正的使用 Git 的时候还需要有远程仓库 repository,否则就是“无米炊”

使用 Git 来工作


接下来看看如何使用最基本的 Git 命令来完成工作。

因为需要远程仓库的支持,所以我们应该先选择一个代码托管平台,比如说 码云,比如说 GitHub。我们的代码将托管在这些平台上,并使用 Git 工具来进行代码的更新(版本管理)

在码云上创建与删除远程仓库

OMG,我把密码忘了。。。。。。


Git 全局设置(初次使用时设置):

git config --global user.name "Mark_Han"
git config --global user.email "hanshikaiapple@gmail.com"

创建 git 仓库:

mkdir DEMO
cd DEMO
git init
touch README.md
git add README.md
git commit -m "first commit"
git remote add origin https://git.oschina.net/markhan/DEMO.git
git push -u origin master

已有项目?

cd existing_git_repo
git remote add origin https://git.oschina.net/markhan/DEMO.git
git push -u origin master

Here is a cheat sheet for git
https://services.github.com/kit/downloads/github-git-cheat-sheet.pdf

相关文章

  • git

    初识git--步骤截图

  • Git 系列文章

    GIT 初识 Git的基础操作 Git的远程操作 Git的分支管理 Git标签操作 Git团队协作 Git 多账户...

  • git命令上

    第2节:git命令 git初识配置 检验git安装是否成功:git bash中运行 git --version验证...

  • GIT和Github

    #Git的初识 ##Git 的使用 Git 使用初尝试 新建项目来操作 克隆已有项目来操作 Git 的使用 by ...

  • # 初识git

    安装教程 可以从Git官网直接下载,网速慢的可以获取网盘资源,然后按默认选项安装即可。安装完成后,在开始菜单里找到...

  • 初识git

    git status 查看当前状态 stage区域的 增,改:git add 删:git rm --cached ...

  • 初识git

    --mkdir learngit 创建learngit文件夹 --进入新建的文件夹 --git init把这个目录...

  • 初识git

    一、版本管理 版本管理,是用来记录一个或若干文件内容变化,以便将来查询特定版本修证情况的系统。 版本管理工具的发展...

  • 初识git

    1,分支管理 都是指针,master指向最新的提交,head指向当前分支 初始情况(只有默认的master指针) ...

  • 初识Git

    Git是一款免费、开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目。本周初识Git 所以整理成博客加...

网友评论

      本文标题:初识 Git

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