Git - 分布式版本控制系统
Author : wMIu - 王宇航
初始化配置 : config
git config --system [option] : 配置系统git config --global [option] : 配置当前用户git config [option] : 配置当前项目git config --list : 查看配置信息
config option
user.name : 配置姓名
user.email : 配置邮箱
core.editor [compiler] : 配置编译器
Git命令
基础命令
git init : 初始化仓库git status : 查看本地仓库状态git add [files] : 将工作区内容记录到暂存区git rm --cached [file] : 取消文件暂存记录git commit [file] -m [message] : 将文件同步到本地仓库git log : 查看全部日志记录git diff [file] : 比较工作区文件和仓库文件差异git checkout -- [file] : 放弃工作区文件修改git checkout [file] : 从仓库区恢复文件git mv [file] [path] : 移动文件git rm [files] : 删除文件
版本控制命令
git reset --hard HEAD^ : 退回到上一个节点git reset --hard [commit_id] : 退回到指定节点git reflog : 查看所有操作记录git tag [tag_name] [commit_id] -m [message] : 创建标签git tag : 查看标签列表git show [tag_name] : 查看标签详细信息git reset --hard [tag] : 去往指定标签节点git tag -d [tag] : 删除标签
工作区命令
git branch : 查看分支情况git branch [branch_name] : 创建分支git checkout [branch] : 切换工作分支git checkout -b [branch] : 创建并切换到该分支git merge [branch] : 合并分支git branch -d [branch] : 删除合并分支git branch -D [branch] : 删除未合并分支
远程仓库命令
git init --bare xxx.git : 初始化共享目录git remote add [shortname] [url] : 添加远程仓库git remote : 查看连接远程主机git remote rename [remote_name] [new_remote_name] : 更改远程主机名git remote rm [shortname] : 删除远程主机git push -u -[remote_name] [branch_name] : 将本地分支推送给远程仓库git branch -a : 查看所有分支git push [remote_name] [:branch_name] : 删除远程分支git push [remote_name] [tag] : 推送本地标签到远程git push [remote_name] --delete tag [tag_name] : 删除远程仓库标签git clone [url] : 克隆远程仓库git pull [remote_name] [remote_branch_name] :[branch_name] : 从远程仓库拉取代码并合并git fetch [remote_name] [remote_branch_name] :[branch_name] : 从远程仓库拉取代码