如何在Git中保存本地和远程存储库之间的某些文件差异?(How can I maintain some file differences between my local and the remote

编程入门 行业动态 更新时间:2024-10-25 22:34:55
如何在Git中保存本地和远程存储库之间的某些文件差异?(How can I maintain some file differences between my local and the remote repository in Git?)

我对存储库的本地克隆进行了一些更改,并将它们提交到本地分支。 我们称这些更改为“提交A”。 我想继续工作在提交A之上,但是当我准备好合并回主分支时,我不想提交合并。

我想我可以使用git rebase -i并删除提交A,但是有没有办法让该提交保持活动状态,以便将来的工作可以完成? 然后,再次,工作合并回主分支而无需提交A.

我意识到我所做的有点粗略,但是在提交A中改变的行与其上面的工作是正交的。 这些更改与机器(生产和测试)之间的差异有关,因为它们必须引用不同版本的第三方库。

I made some changes to my local clone of a repository and committed them in a local branch. Let's call these changes "commit A". I want to keep working on top of commit A, but when I'm ready to merge back into the main branch I don't want commit A merged.

I'm thinking I can use git rebase -i and delete commit A, but is there a way to keep that commit alive, so that future work can be done on top of it? And then, again, the work merged back to the main branch without commit A.

I realize that what I'm doing is a bit sketchy, but the lines changed in commit A are orthogonal to the work on top of it. The changes are related to differences between machines (production and testing) because they must reference different versions of a third-party library.

最满意答案

我想我可以使用git rebase -i并删除提交A,但是有没有办法让该提交保持活动状态,以便将来的工作可以完成? 然后,再次,工作合并回主分支而无需提交A.

你可以给它加标签。 从分支中删除的提交不会消失。 然后当你需要它时,你可以挑选标签。 那是:

git tag somename SHA1 ... git rebase -i OLDREV ... git cherry-pick somename

I'm thinking I can use git rebase -i and delete commit A, but is there a way to keep that commit alive, so that future work can be done on top of it? And then, again, the work merged back to the main branch without commit A.

You can tag it. The commit deleted from the branch will not be gone. And then later when you need it, you can cherry-pick the tag. That is:

git tag somename SHA1 ... git rebase -i OLDREV ... git cherry-pick somename

更多推荐

本文发布于:2023-08-05 06:24:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1430177.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:差异   文件   如何在   Git   maintain

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!