how to combine commits and push to the remote

≯℡__Kan透↙ 提交于 2019-12-11 18:43:47

问题


At the beginning the local branch is uptodate and now I use git rebase -i HEAD~3 and modify the pick of the two newest commits to fixup to combine 3 commits at the local branch,and now I want to push the local branch to the remote. And I only want to show a combined commit at the remote. However,after combined the local branch falls behind with remote by two commits and I cannot push directly. How can I deal with it?


回答1:


DISCLAIMER: git push --force is dangerous; use it at your own risk.

If you really want to do this and combine commits, you could do it on your local repository using git squash and then git push --force in order to overwrite the content on the remote.

--

Note that git push --force will update the branch to point to your new commits, so the old commits will be inaccessible permanently unless you have the commit identifier or a way to find it and the commit hasn't been garbage-collected. This is generally not possible on hosted git services, though GitHub does have an activity log.

In addition, git push --force can cause issues if other people are working on the same branch and are not expecting the change.



来源:https://stackoverflow.com/questions/50491446/how-to-combine-commits-and-push-to-the-remote

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!