问题描述
我有一个显示太多提交的github存储库,我想将它们压缩成一个。
有没有办法让这些提交看起来像我当前的本地回购? - 解决方案
我有一个显示太多提交的github存储库,我想将它们压缩成一个。
有没有办法让这些提交看起来像我当前的本地回购? - 解决方案
您可以压缩提交通过使用交互式重新分配您的本地回购。
git push -f
但是,如果有其他人也在处理您的github回购请注意,因为您可能会失去提交。我通常只会强制推行回购/分支机构,而我是唯一承诺的分支机构。也默认git推动所有分支。因此,指定要推送的分支是一个好主意,即
git push -f origin master
我已经设置了我的git来只推送当前分支,以避免由于错误造成的远程回购。
git config --global push.default current
I have a github repository that shows too many commits and i want to squash them into one.Is there a way to make these commits look like my current local repo exactly?
You can squash commits on your local repo by using interactive rebase. After that you can use force push.
git push -f
But be careful if there are anybody else also working on your github repo, as you might lose commits. I usually only force push to repos/branches where I'm the only one commiting to it. Also by default git pushes all branches. So it's a good idea to specify what branch you want to push i.e.
git push -f origin master
I've set up my git to only push the current branch to avoid messing up the remote repo by a mistake.
git config --global push.default current
这篇关于如何将许多提交合并到github存储库中的一个提交中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!