最近项目中使用github来管理代码,将git的常用命令整理了一下,方便以后查询
查看git的本地配置
git config --list
克隆到本地
git clone (网页上面的那个http地址 git@...)
设置全局配置
git config --global user.name "kkkk"
删除全局配置
git config --unset --global user.name "用户名"
git config --unset --global user.email "邮箱号"
查看分支
git branch
切换分支
git checkout 分支名
删除分支
git push origin --delete 分支名
添加文件到库中
git add 文件名
提交代码到本地库
git commit -m "注释文字"
推送到远程库
git push 远程名 本地的分知名
查看远程名
git remote
合并分支,将其他分支与当前分支进行合并
git merge 其他分知名
查看修改状态
git status
查看修改日志
git log
fork后,添加原始远程库或者分支
git remote add 远程名(可以自定义) git的http地址
获取源更新
git pull <远程主机名> <远程分支名>:<本地分支名>
远程仓库重命名
git remote rename 原名 新的名字
删除远程仓库
git remote rm github