标签:mic 分支 gpl folder auth 工作区 最新 git add dir
git add fileName/folderName
git commit -m "修改的内容"
git clone ****
git push
# 查看此时是否add、是否commit等
$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: readme.txt
no changes added to commit (use "git add" and/or "git commit -a")
# 查看文件修改的内容
$ git diff readme.txt
diff --git a/readme.txt b/readme.txt
index 46d49bf..9247db6 100644
--- a/readme.txt
+++ b/readme.txt
@@ -1,2 +1,2 @@
-Git is a version control system.
+Git is a distributed version control system.
Git is free software.
# 查看工作区和版本库里面最新版本的区别
$ git diff HEAD -- readme.txt
# 查看修改日志
$ git log
commit 1094adb7b9b3807259d8cb349e7df1d4d6477073 (HEAD -> master)
Author: Michael Liao <askxuefeng@gmail.com>
Date: Fri May 18 21:06:15 2018 +0800
append GPL
# 每个日志输出一行
$ git log --pretty=oneline
1094adb7b9b3807259d8cb349e7df1d4d6477073 (HEAD -> master) append GPL
# 回退上一个版本
$ git reset --hard HEAD^
# 回退上上个版本
$ git reset --hard HEAD^^
# 回退100个版本前
$ git reset --hard HEAD~100
# 1094a由git log和git reflog得到
# git log得到之前的修改ID
# git reflog得到当前修改版本的未来的ID
$ git reset --hard 1094a
# 适用于未 git commit 的情况
# 将文件恢复至上一个commit的版本
$ git checkout -- readme.txt
# 适用于已经 git commit 后
$ git reset HEAD readme.txt
$ git checkout -- file
$ rm test.txt
$ git rm test.txt
$ git commit -m "remove test.txt"
# 把误删的文件恢复到最新版本
$ git checkout -- test.txt
# 创建并切换分支
$ git checkout -b branchName
$ git switch -c branchName
# 查看当前分支
$ git branch
# 切换回master分支
$ git checkout master
$ git switch master
# 删除分支
$ git branch -d branchName
# master分支更新为dev分支
$ git merge dev
# 把当前工作现场“储藏”起来
$ git stash
# 恢复git stash 的内容
$ git stash list
$ git stash pop
标签:mic 分支 gpl folder auth 工作区 最新 git add dir
原文地址:https://www.cnblogs.com/HurryXin/p/13131058.html