Git常用命令
非详细教程,仅供查阅
-
修改本地 hosts,你会发现 github 快了很多
linux: /etc/hosts windows: C:\Windows\System32\drivers\etc\hostslinux: /etc/init.d/networking restart windows:ipconfig /flushdns199.232.69.194 github.global-ssl.fastly.net 140.82.112.4 github.com -
git初始认证
ssh-keygen -t rsa -C "717632318@qq.com" 生成秘钥对 将.ssh/id_rsa.pub 中的公钥放到github中 git config --global user.name "jun.fan" git config --global credential.helper store -
初始化目录
git init -
添加文件
git add <filename> -
删除文件
git rm <filename> -
提交
git commit -m "log" <filename> -
查看修改状态
git status -
查看提交日志
git log git log --pretty=online -
检出提交过的文件
git checkout --<filename> -
回滚到某一版本号
git reset --hard <commititd> -
查看操作过命令日志
git reflog -
拉取远程库,两种方法,分别使用两种协议
git clone https://github.com/fancygo/hello.git git clone git@github.com:fancygo/hello.git -
将本地库与远程库链接
git remote add origin git@github.com:fancygo/*.git -
提交本地库修改到远程
git push origin master -
拉取远程库修改
git pull origin master -
打tag
git tag <tagver> -
提交tag
git push origin <tagver> git push --tags -
创建并切换分支
git checkout -b <branchver> -
提交分支
git push -u oring <branchver> -
创建分支
git branch <branchver> -
切换分支
git checkout <branchver> -
查看分支
git branch -a git branch -
合并分支到当前分支
git merge <ver> -
删除分支
git branch -d <ver> -
查看远程库信息
git remote -v -
子模块更新
git submodule update human
