要注意尽可能不要往git上提交二进制文件,二进制文件是不按diff保存的,即便提交了也不要每次改一点而后再提交一遍。git
一:常规办法
1.删除无用的分支github
$ git branch -d <branch_name>
2.删除无用的tagbootstrap
$ git tag -d <tag_name>
3.清理本地版本库jsp
$ git gc --prune=now
二:高级办法
注意高级办法会致使push冲突,须要强制提交,其余人pull也会遇到冲突,建议从新克隆。
!!!注意这些操做都很危险,建议找个示例库进行测试,确保本身彻底掌握以后再实际操做。测试
1.彻底重建版本库url
$ rm -rf .git $ git init $ git add . $ git commit -m "first commit" $ git remote add origin <your_github_repo_url> $ git push -f -u origin master
2.有选择性的合并历史提交code
$ git rebase -i <first_commit>
会进入一个以下所示的文件orm
1 pick ba07c7d add bootstrap theme and format import 2 pick 7d905b8 add newline at file last line 3 pick 037313c fn up_first_char rename to caps 4 pick 34e647e add fn of && use for index.jsp 5 pick 0175f03 rename common include 6 pick 7f3f665 update group name && update config
将想合并的提交的pick改为s,如rem
1 pick ba07c7d add bootstrap theme and format import 2 pick 7d905b8 add newline at file last line 3 pick 037313c fn up_first_char rename to caps 4 s 34e647e add fn of && use for index.jsp 5 pick 0175f03 rename common include 6 pick 7f3f665 update group name && update config
这样第四个提交就会合并进入第三个提交。
等合并完提交以后再运行it
$ git push -f $ git gc --prune=now