小白教程
所有教程
关于
Search
162.158.158.107
162.158.158.107
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Git 基本操作”的源代码
本页内容
上一节:
Git_创建仓库
下一节:
Git_分支管理
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:Git 基本操作}}[[Category:Git 教程|6]] = Git 基本操作 = Git 的工作就是创建和保存你项目的快照及与之后的快照进行对比。 本章将对有关创建与提交你的项目快照的命令作介绍。 Git 常用的是以下 6 个命令:'''git clone'''、'''git push'''、'''git add''' 、'''git commit'''、'''git checkout'''、'''git pull''',后面我们会详细介绍。 '''说明:''' * workspace:工作区 * staging area:暂存区/缓存区 * local repository:版本库或本地仓库 * remote repository:远程仓库 一个简单的操作步骤: <sample title="" desc="" lang="shell" hererun="1"> $ git init $ git add . $ git commit </sample> * git init - 初始化仓库。 * git add . - 添加文件到暂存区。 * git commit - 将暂存区内容添加到仓库中。 === 创建仓库命令 === 下表列出了 git 创建仓库的命令: {| class="table table-striped table-hover" ! 命令 ! 说明 |- | [[git init|<code>git init</code>]] | 初始化仓库 |- | [[git clone|<code>git clone</code>]]<code> </code> | 拷贝一份远程仓库,也就是下载一个项目。 |} == 提交与修改 == Git 的工作就是创建和保存你的项目的快照及与之后的快照进行对比。 下表列出了有关创建与提交你的项目的快照的命令: {| class="table table-striped table-hover" ! 命令 ! 说明 |- | [[git add|<code>git add</code>]] | 添加文件到暂存区 |- | [[git status|<code>git status</code>]]<code> </code> | 查看仓库当前的状态,显示有变更的文件。 |- | [[git diff|<code>git diff</code>]]<code> </code> | 比较文件的不同,即暂存区和工作区的差异。 |- | [[git commit|<code>git commit</code>]]<code> </code> | 提交暂存区到本地仓库。 |- | [[git reset|<code>git reset</code>]]<code> </code> | 回退版本。 |- | [[git rm|<code>git rm</code>]]<code> </code> | 将文件从暂存区和工作区中删除。 |- | [[git mv|<code>git mv</code>]]<code> </code> | 移动或重命名工作区文件。 |} === 提交日志 === {| class="table table-striped table-hover" ! 命令 ! 说明 |- | [[git commit history#git log|<code>git log</code>]] | 查看历史提交记录 |- | [[git commit history#git blame|<code>git blame <file></code>]]<code> </code> | 以列表形式查看指定文件的历史修改记录 |} === 远程操作 === {| class="table table-striped table-hover" ! 命令 ! 说明 |- | [[git remote|<code>git remote</code>]] | 远程仓库操作 |- | [[git fetch|<code>git fetch</code>]]<code> </code> | 从远程获取代码库 |- | [[git pull|<code>git pull</code>]]<code> </code> | 下载远程代码并合并 |- | [[git push|<code>git push</code>]]<code> </code> | 上传远程代码并合并 |}
返回至“
Git 基本操作
”。
上一节:
Git_创建仓库
下一节:
Git_分支管理