git 命令使用技巧
1.如果使用htts协议,需要执行初始化命令,并保存账号密码
保存账号密码 git config --global credential.helper store 取消ssl验证 git config --global http.sslVerify false 忽略文件夹权限 git config core.filemode false
2.切换到本地没有而远程服务器有的分支
git fetch --all git checkout -f branch_name
3.代码回滚
git reset --hard the_commit_id --回滚到某commit_id的版本
4.放弃所有本地修改,跟远程服务器保持一致
git reset --hard origin/branch_name
5.查看所有分支
git branch -a
6.查看代码仓库地址
git remote -v
7.修改远程仓库地址
git remote set-url origin remote_url
8.查看历史commit信息
git log git log --stat #显示近几次提交更新文件的内容。(可显示最近提交人) git log --pretty=oneline --stat #仅仅显示最近提交更新的内容(不显示最近提交人)
9.创建新的分支
git branch branch_name git checkout -b branch_name
10.从一个分支推送到另外一个分支
git push origin branch_name_a:branch_name_b