Git 命令必知必会汇总
1. Setup & Init 基本的设置和初始化
//initialize an existing directory as a Git repository
git init
git clone [url]
retrieve an entire repository from a hosted location via URL
2 . stage & snapshot & .git directory 工作区,暂存区和.git目录
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-3SMsTJ9e-1571631203239)(https://miro.medium.com/max/1770/0*I9eMyrVXVz9ctChI.)]
git status
show modified files in working directory, staged for your next commit
git add [file]
add a file as it looks now to your next commit (stage)
git add -u
git add .
-
Changes to be committed:
-
Changes not staged for commit:
-
Untracked files:
3 . Git diff 找不同
git diff
diff of what is changed but not staged
git diff --staged
diff of what is staged but not yet commited
git diff -cached // 效果和staged 一样
4. 把已经加入staged的文件打上Commit 标记
git commit -m “[descriptive message]”
commit your staged content as a new commit snapshot
5. BRANCH & MERGE
git branch
list your branches. a * will appear next to the currently active branch
git</