工作区(working diretory) 用于修改文件缓存区(stage) 是用来暂时存放工作区中修改的内容 提交历史(commit history) 提交代码的历史记录 主要的几个命令 git add # 将工作区的修改提交到暂存区 git commit # 将暂存区的修改提交到当前分支 git reset # 回退到某一个版本 git stash # 保存某次修改 git pull #...
abc1234Commit1def5678Commit2ghi9012Commit3 切换到 Commit 2(处于分离头指针状态): git checkout def5678 重置到 Commit 2,保留更改到暂存区: git reset--soft def5678 重置到 Commit 2,取消暂存区更改: git reset--mixed def5678 重置到 Commit 2,丢弃所有更改: git reset--hard def5678 撤销Commit 2: ...
# 首先,需要将 should-commit.js 文件添加到暂存区git add should-commit.js# 其次,将 should-not-commit.js 文件从已暂存状态转为未暂存状态,不会删除 should-not-commit.js 文件。git rm --cache should-not-commit.js# 最后,通过git commit --amend 修改提交信息git commit--amend 当键入 git commit —...
After you have created several commits, or if you have cloned a repository with an existing commit history, you’ll probably want to look back to see what has happened. The most basic and powerful tool to do this is thegit logcommand. These examples use a very simple project called “sim...
git rebase是对commit history的改写。当你要改写的commit history还没有被提交到远程repo的时候,也就是说,还没有与他人共享之前,commit history是你私人所有的,那么想怎么改写都可以。 而一旦被提交到远程后,这时如果再改写history,那么势必和他人的history长的就不一样了。git push的时候,git会比较commit history,...
本地版本库(Local Commit History):存放所有已经提交的数据,通过git push推送到远程仓库。 基础命令 === git status 查看工作区状态,如果跟踪的文件有做任何修改,都可以通过该命令来发现。 如:这里通过git status就发现在develop分支上,README.md文件发生了更改。 代码...
by using the --interactive or --patch switches with thecommitcommand to decide one by one which files or hunks should be part of the commit in addition to contents in the index, before finalizing the operation. See the “Interactive Mode” section ofgit-add[1]to learn how to operate thes...
输出暂存区和本地最近的版本(commit)的different(不同)。 git diff --cached 展示暂存区、工作区和最近版本的不同 输出工作区、暂存区和本地最近的版本(commit)的different(不同)。 git diff HEAD 快速切换分支 git checkout - 删除已经合并到master的分支 ...
最常见的问题就是乱成一团的 git log history,那真的是老太太的裹脚布, 又臭又长, 个人极其不喜欢这种 log 造成这个问题的根本原因就是随意提交代码。代码都提交了,那还有什么办法拯救吗?三个锦囊,就可以完美解决了 善用 git commit --amend 这个命令的帮助文档是这样描述的:--amend amend previous comm...
常用于移出暂存区的文件以作为 add 命令的反动作git reset (--mixed) <commitId>/<branch>// 执行 123。常用于无条件放弃本地所有变更以向远程分支同步git reset --hard <commitId>/<branch>// 将暂存区的所有改动撤销到工作区git reset (--mixed) HEAD clean 用来从工作目录中删除所有没有 tracked 过的...