步骤:
暂存add- 提交commit- 推送push
git status # 查看工作区 绿色为暂存区文件
git status -s # 简洁输出模式
git add .
git commit -m 'message'
----------------------------------------------------------------
# 分支操作
git branch # 检查分支
git branch [branchname] # 新建分支
git checkout -b [branchname] # 新建分支并且切换到新分支
git branch -d [branchname] # 删除本地分支
# -r 远程分支 -a 查看全部分支
git checkout [branchname] # 切换分支
# 删除远程分支
git push [remotename] -d [remote branchname]
git push [remotename] :[remote branchname] # 两条命令等效
# 为游离HEAD创建新分支
git branch [new_branchname] [commit_id]
git log # 查看本地commit记录
git log [remote branch] # 查看远程commit记录
# 提交,自动创建远程分支
git push [remotename] [local branchname]:[remote branchname]
----------------------------------------------------------------
git stash # 清空当前工作区,并将其保存
git stash save 'message'
git reflog # 查看本地操作记录
git reset --hard [op_id] # 回撤本地操作,包括reset rebase commit等等
----------------------------------------------------------------
# 查看提交修改
git show # 查看最后一次提交
git show --raw # 查看修改文件信息
git show --raw [commit_id] # 指定提交
git show [commit_id] [filename] # 查看具体文件的修改
# 合并提交
git rebase -i HEAD~n
.gitattributes
.gitignore 告诉git忽略一些文件,git status时不跟踪这些文件的状态
.gitkeep
git分支版本管理
文件状态符号说明
A: 你本地新增的文件(服务器上没有)
C: 文件的一个新拷贝.
D: 你本地删除的文件(服务器上还在).
M: 文件的内容或者mode被修改了.
R: 文件名被修改了。
T: 文件的类型被修改了。
U: 文件没有被合并(你需要完成合并才能进行提交)。
X: 未知状态(很可能是遇到git的bug了,你可以向git提交bug report)
报错
1. fatal: detected dubious ownership in repository at ...
这是因为该项目的所有者与现在的用户不一致
比如说: 该项目的所有者是 Administrator,而当前用户是 qiuye, 那么就会导致上面的错误
git config --global --add safe.directory "*"