zoukankan      html  css  js  c++  java
  • Git的用法

    Git的用法

    Git 的也可以理解为版本控制器。版本控制器(维基的解释):维护工程蓝图的标准作法,能追踪工程蓝图从诞生一直到定案的过程。此外,版本控制也是一种软件工程技巧,借此能在软件开发的过程中,确保由不同人所编辑的同一代码文件案都得到同步。

    非常适合团队开发大型项目。可以放心大胆的进行代码修改,如果出错可以回复之前提交过的任何版本(前提是你的提交比较合理),而且可以合并不同的分支中不同的版本。

    Git 的下载

    百度网盘(windows 64bit):http://pan.baidu.com/s/1nv2PM33    

    git官网:https://git-scm.com/downloads

    Git 本地代码库的使用

    进入你想进行同步的目录下,使用cd + [路径]的命令。或者直接进入到文件目录下,右键选择Git Bash Here/Git GUI Here。

    创建本地代码库,使用git init命令,git会在目录下创建一个隐藏文件.git。此文件千万不能删。

    提交代码。可以将git 作用的空间抽象为3个:工作目录(Working area),暂存区(Starging area),仓库(repository)。

    工作目录就是你当前目录下的文件。

    暂存区是用来暂存更改的文件的,放在工作目录和仓库中间,用来过度的。只能提交暂存区的文件,不能直接提交工作目录。

    仓库保存了之前提交的所有记录,可以使用git log命令查看所有提交,而且可以回退到任意提交记录。

    因为不能直接提交工作目录中更改的文件,所以必须使用git add [文件名]加入到暂存区,然后git commit提交。如果你不知道哪些文件更改了使用git status查看目前所有的更改。

    Git 与 远程代码库的链接(与github的连接)

    创建github账户,创建工程。Github对每一个创建的工程都会创建一个远程同步接口。通常我们使用https来提交本地保存的代码库。

    使用git remote add [远程版本库名(origin)] [URL]命令,创建远程版本库连接。可以使用命令git remote来查看是否创建成功。如果创建成功显示远程版本库名。

    使用git push[远程版本库名] [要推送的本地分支]命令,推送分支。

    Git 附录

    Git常用命令

    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

  • 相关阅读:
    C++字符串以及转换整理
    Chromium 调试其他的进程
    Cstring和wstring互转
    注册表写入
    inno setup需要管理员权限
    C++ 新增的算法
    节选-文件描述符
    原创-docker镜像迁移另外仓库
    2021初赛:毒瘤汇总
    二维计算几何基础
  • 原文地址:https://www.cnblogs.com/StrayWolf/p/6241666.html
Copyright © 2011-2022 走看看