在多台计算机上工作时如何安全地使用 git rebase?
我在两台不同的计算机(台式机和笔记本电脑)上处理同一个项目。有时我需要在执行某些任务/功能时在它们之间进行转换。
因此,我想在笔记本电脑上进行提交,然后将其传输(推/拉)到桌面并继续。然后,当该功能完成时,我想进行一个新的提交,然后用半完成的提交来压缩它。
我现在如何将其拉/推回笔记本电脑而不混淆历史记录?
处理此问题的正确方法是什么?完成此操作后,我还必须能够发布提交。目前我正在直接在主分支上工作,但如果在单独的分支上工作有帮助,我会这样做。
我确实知道如何使用 git rebase -i,并且在同一台计算机上使用过几次,没有出现任何问题,因此您的答案不必包含 git rebase/squash 的详细信息。
I work on the same project on two different computers, desktop and laptop. Sometimes I need to transition between them while in the middle of some task/feature.
So I want to make a commit on the laptop, and then transport (push/pull) it to the desktop and continue. Then, when the feature is complete I want to make a new commit and then squash it with the half-done commit.
How can I now pull/push it back to the laptop without confusing the history?
What's the proper way of handling this? After doing this, I must also be able to publish the commits. Currently I'm working on the master branch directly, but if working on a separate branch helps I will do that.
I do know how to use git rebase -i, and have used it a few times while still on the same computer without a problem, so your answer does not have to include the details of git rebase/squash.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我一直这样做,并使用以下工作流程,当我不在任何给定计算机前时,使用 github 作为权威主存储库:
当我离开计算机时,我总是
我
只要我总是做同样的事情,我知道我的最新工作总是在 github 上,并且我会重新设置我想要的所有内容,
通常也会设置
只推送我已签出的分支,我发现这几乎是强制性的使用大量的强制推动。
I do this all the time and use the following workflow, using github as an authorative master repository when I'm not sitting at any given computer:
When I leave a computer i always do
When I arrive at a computer I do
As long as I always do the same, I know my latest work is always on github, and I rebase all I want
I generally also set
to push only the branch I have checked out, something I find to be almost mandatory when using a lot of forced push.