git add * # 跟踪新文件 git add -u [path] # 添加[指定路径下]已跟踪文件
rm *&git rm * # 移除文件 git rm -f * # 移除文件 git rm --cached * # 停止追踪指定文件,但该文件会保留在工作区 git mv file_from file_to # 重命名跟踪文件
git log # 查看提交记录
git commit # 提交更新 git commit [file1] [file2] ... # 提交指定文件 git commit -m 'message' git commit -a # 跳过使用暂存区域,把所有已经跟踪过的文件暂存起来一并提交 git commit --amend#修改最后一次提交 git commit -v # 提交时显示所有diff信息
git reset HEAD *#取消已经暂存的文件 git reset --mixed HEAD *#同上 git reset --soft HEAD *#重置到指定状态,不会修改索引区和工作树 git reset --hard HEAD *#重置到指定状态,会修改索引区和工作树 git reset -- files#重置index区文件
git revert HEAD #撤销前一次操作 git revert HEAD~ #撤销前前一次操作 git revert commit ## 撤销指定操作
git checkout -- file#取消对文件的修改(从暂存区——覆盖worktree file) git checkout branch|tag|commit -- file_name#从仓库取出file覆盖当前分支 git checkout -- .#从暂存区取出文件覆盖工作区
git diff file #查看指定文件的差异 git diff --stat #查看简单的diff结果 git diff #比较Worktree和Index之间的差异 git diff --cached #比较Index和HEAD之间的差异 git diff HEAD #比较Worktree和HEAD之间的差异 git diff branch #比较Worktree和branch之间的差异 git diff branch1 branch2 #比较两次分支之间的差异 git diff commit commit #比较两次提交之间的差异
git log #查看最近的提交日志 git log --pretty=oneline #单行显示提交日志 git log --graph # 图形化显示 git log --abbrev-commit # 显示log id的缩写 git log -num #显示第几条log(倒数) git log --stat # 显示commit历史,以及每次commit发生变更的文件 git log --follow [file] # 显示某个文件的版本历史,包括文件改名 git log -p [file] # 显示指定文件相关的每一次diff
git stash #将工作区现场(已跟踪文件)储藏起来,等以后恢复后继续工作。 git stash list #查看保存的工作现场 git stash apply #恢复工作现场 git stash drop #删除stash内容 git stash pop #恢复的同时直接删除stash内容 git stash apply stash@{0} #恢复指定的工作现场,当你保存了不只一份工作现场时。
|
Related Issues not found
Please contact @poetries to initialize the comment