Git通过svn

系统教程 行业动态 更新时间:2024-06-14 17:01:34
Git通过svn - 管理文件(Git through svn - managing files)

也许我错过了一些关于通过svn使用gi的东西,但是如何在不将这些更改推送到subversion的情况下保留一组本地修改的文件。

这是我破碎的工作流程。

(on master) git svn rebase git checkout -b issue *apply changes I need on all my branches* *changes* git commit *changes* git checkout master git merge issue git svn dcommit

问题在于svn rebase,甚至提交,我丢失了我的本地修改但未签入的文件。 我不想提交文件,因为我不希望它们被拉入svn提交。

我的工作流程应该如何在这样的情况下工作?

Perhaps I'm missing something about using gi through svn, but how do I keep around a set of locally modified files without pushing those changes to subversion.

Here's my broken workflow.

(on master) git svn rebase git checkout -b issue *apply changes I need on all my branches* *changes* git commit *changes* git checkout master git merge issue git svn dcommit

The problem lies in the fact that svn rebase, or even committing, I lose my locally modified but not checked in files. I don't want to commit the files, because I don't want them pulled into an svn commit.

How is my workflow supposed to work in a situation like this?

最满意答案

我的git-svn工作流程看起来像这样:

(on master) git svn rebase git checkout work ... make commits for all changes, including local-only and those I intend to push up git checkout master ... cherry-pick changes from work branch git svn dcommit git checkout work git rebase master

最后一个rebase步骤将删除已在上游提交的工作分支的所有提交。

对于cherry-pick步骤,我实际上使用了一个小的shell脚本,它自动获取所有提交, 除了那些在描述中有“NOCOMMIT”的提交。 你可以使用另一个指标,如“LOCAL”或“NOPUSH”或任何你喜欢的。 这些提交是那些在“工作”分支上徘徊并且没有被推到Subversion的提交。

这是我的pull-work脚本:

#!/bin/sh BRANCH=`git branch | grep ^\\* | cut -d' ' -f2` if [ $BRANCH != "master" ]; then echo "$0: Current branch is not master" exit 1 fi git log --pretty=oneline work...master | grep -v -E '(NOCOMMIT|DEBUG):' | cut -d' ' -f1 | tac | xargs -l git cherry-pick

注意使用像tac这样的细微tac来反转列出的提交的顺序,以便它们以相同的顺序应用于master。

My git-svn workflow looks something like this:

(on master) git svn rebase git checkout work ... make commits for all changes, including local-only and those I intend to push up git checkout master ... cherry-pick changes from work branch git svn dcommit git checkout work git rebase master

The last rebase step removes all the commits from the work branch that have already been committed upstream.

For the cherry-pick step, I actually use a small shell script that automatically gets all the commits except those that have "NOCOMMIT" in their description. You could use another indicator like "LOCAL" or "NOPUSH" or whatever you like. These commits are those which hang around on the "work" branch and aren't pushed up to Subversion.

Here's my pull-work script:

#!/bin/sh BRANCH=`git branch | grep ^\\* | cut -d' ' -f2` if [ $BRANCH != "master" ]; then echo "$0: Current branch is not master" exit 1 fi git log --pretty=oneline work...master | grep -v -E '(NOCOMMIT|DEBUG):' | cut -d' ' -f1 | tac | xargs -l git cherry-pick

Note the use of subtleties like tac that reverse the order of the listed commits so they get applied to master in the same order.

更多推荐

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

发布评论

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

>www.elefans.com

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