git使用命令整理

来源:互联网 发布:php文件上传 编辑:程序博客网 时间:2024/05/22 06:46

Git 是当前最流行的版本控制程序之一,文本包含了 Git 的一些基本用法 创建 git 仓库 初始化 git 仓库 

Git 命令示例:

mkdir project  # 创建项目目录 

cd project  # 进入到项目目录 

git init  # 初始化 git 仓库。此命令会在当前目录新建一个 .git 目录,用于存储 git 仓库的相关信息 

初始化提交 

touch README 

git add .  # 将当前目录添加到 git 仓库中, 使用 git add -A 则是添加所有改动的文档 

git commit  -m  "Initial commit" 

git remote add origin  git @github.com:lugir /repo.git  # 设置仓库 

修补提交(修补最近一次的提交而不创建新的提交) 

git commit  --amend  -m  "commit message." 

提交冲突时可以合并后再推送 

git pull  # 获取远程版本库提交与本地提交进行合并 

git push  # 提交 

使用别人的仓库 

git clone http: //path /to /git.git  # clone 的内容会放在当前目录下的新目录 

将代码从本地回传到仓库 

git push  -u origin master 

使用 git status 查看文件状态 

git status 

查看提交日志 

git log  # 查看提交信息 

git log  --pretty=oneline  # 以整洁的单行形式显示提交信息 

Git 分支 

git branch  # 查看分支 

git branch  6.x- 1.x  # 添加分支 6.x-1.x 

git branch checkout master  # 切换到主分支 

git branch  -d  6.x- 1.x  # 删除分支 6.x-1.x 

git push origin :branchname  # 删除远端分支 

Git 标签 

git tag  # 查看分支 

git tag  6.x- 1.0  # 添加标签 6.x-1.0 

git show  6.x- 1.0  # 查看标签 6.x-1.0 的信息 

git tag  -a  6.x- 1.0 965e066  # 为之前提交的信息记录 965e066 加上标签 

git push  --tags  # 提交时带上标签信息 

git push origin : /refs /tags /tagname  # 删除远端标签 

从 git 仓库中导出项目 

git archive  --format  tar  --output  /path /to /file.tar master  # 将 master 以 tar 格式打包到指定文件 

使用 Git 的一些基本守则: 当要commit/提交patch时: 

·使用 git diff --check 检查行尾有没有多余的空白

·每个 commit 只改一件事情。如果一个文档有多个变更,使用 git add --patch 只选择文档中的部分变更进入 stage

·写清楚 commit message


The most commonly used git commands are:
所有最常用的git命令说明:

 

   add        Add file contents to the index

添加文件的内容添加到索引

 

   bisect     Find by binary search the change that introduced a bug

平分找到通过二进制搜索的变化引入了一个错误

 

   branch     List, create, or delete branches

分支列表、创建或删除分支

 

   checkout   Checkout a branch or paths to the working tree

检出 检出一个分支或路径树

 

   clone      Clone a repository into a new directory

克隆克隆存储库到一个新的目录

 

   commit     Record changes to the repository

提交 记录更改存储库

 

   diff       Show changes between commits, commit and working tree, etc

比较文件的差异显示之间的更改提交,提交和工作树,等等

 

   fetch      Download objects and refs from another repository

取出 从另一个存储库下载对象和参考文献

 

   grep       Print lines matching a pattern

在文件内容中查找 打印模式匹配的行

 

   init       Create an empty Git repository or reinitialize an existing one

初始化 创建一个空的Git存储库或重新启动一个现有的一个

 

   log        Show commit logs

日志 显示提交日志

 

   merge      Join two or more development histories together

合并 一起加入两个或两个以上的发展历史

 

   mv         Move or rename a file, a directory, or a symlink

移动文件 移动或重命名一个文件、目录或符号链接

 

   pull       Fetch from and integrate with another repository or a local branch

获取和整合与另一个存储库或当地的分支机构

 

   push       Update remote refs along with associated objects

提交 更新远程参考文献以及相关的对象

 

   rebase     Forward-port local commits to the updated upstream head

垫底  向本地提交更新的上的头

 

   reset      Reset current HEAD to the specified state

重置重置当前前往指定的状态

 

   rm         Remove files from the working tree and from the index

删除 从工作树,从索引中删除文件

 

   show       Show various types of objects

显示 显示各种类型的对象

 

   status     Show the working tree status

状态 树显示工作状态

 

   tag        Create, list, delete or verify a tag object signed with GPG

标签 创建列表,删除或验证一个标签对象签订GPG

 

Git help -g      
The common Git guides are:
常用的Git指南:

   attributes:   Defining attributes per path

属性:每个路径定义属性

   glossary:     A Git glossary

词汇:一个Git术语

   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)

教程:教程介绍Git(版本1.5.1或更新版本)

   workflows:    An overview of recommended workflows with Git

工作流程:用git推荐流程概述

0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 行驶证检验有效期过期怎么办 驾驶证被扣26分怎么办 c1驾驶证扣26分怎么办 驾驶证被扣6分后怎么办 c1驾照年审过期一天怎么办 审驾照时间过了怎么办 b2驾驶证扣了分怎么办 a2驾照逾期未审怎么办 中学生只想打游戏不肯学习怎么办 汽车4年未年检怎么办 2年没有验车怎么办 驾驶证过期2年半怎么办 审车逾期一个月怎么办 摩托车驾驶证年审过期一个月怎么办 摩托车驾驶证记满12分怎么办 b2驾驶证扣2分该怎么办 b2扣6分以上怎么办 审驾照晚了3天怎么办 考驾驶证3年到期怎么办 学习驾驶证明过期了怎么办 a2扣了12分怎么办 驾照a2扣6分了怎么办 a2本扣9分怎么办 驾驶证分扣3分怎么办? 异地换驾驶证没有居住证怎么办 b2开c1车扣分怎么办 驾照五次没考过怎么办 大车行驶证丢了怎么办 车的产权证丢了怎么办 车子行驶证掉了怎么办 定期的存折丢了怎么办 存折密码输错6次怎么办 营业执照原件丢失怎么办怎么注销 违章扣了14分怎么办 c1驾驶本过期了怎么办 考驾照没带身份证怎么办 上海扣满12分怎么办 美宝旅行证丢失怎么办 汽车证件全丢了怎么办 车的行驶本丢了怎么办 车和行驶证丢了怎么办