如何在 dcommit 之前查看“git svn dcommit”更改?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9775719/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 06:37:37  来源:igfitidea点击:

How to see 'git svn dcommit' changes before dcommitting?

gitsvngit-svn

提问by Frank

With svn-git, how can I see what is about to be committed with git svn dcommit?

有了svn-git,我如何才能看到将要提交的内容git svn dcommit

Here are the commands I run:

这是我运行的命令:

git svn  clone file:///svn/test1 test1-git
cd test1-git
echo "first line" > test1.txt 
git add test1.txt 
git commit 

Now it's committed to the git repository -- good. But before I run git svn dcommitI'd like to see a diff that contains the changes that would be committed to the SVN repository.

现在它已提交到 git 存储库 - 很好。但在我运行之前,我git svn dcommit想查看一个差异,其中包含将提交到 SVN 存储库的更改。

回答by Tomas Markauskas

If your remote branch is called git-svn(it is called that if you just do a plain git svn clone) then you can see a diff between the current branch and git-svn:

如果你的远程分支被调用git-svn(如果你只是做一个普通的就被调用git svn clone)那么你可以看到当前分支和 之间的差异 git-svn

git diff git-svn HEAD

You would see all changes that are present in your current branch but not in the svn repository.

您将看到当前分支中存在但不在 svn 存储库中的所有更改。

回答by MKK

The output of 'git svn dcommit --dry-run' can be fed to git again like so:

'git svn dcommit --dry-run' 的输出可以像这样再次提供给 git:

git diff-tree 2282c630eeef26fecbc3f3519be55a9dce094c80~12282c630eeef26fecbc3f3519be55a9dce094c80 -u

Note the '-u' at the end. You will then see a diff.

注意末尾的“-u”。然后你会看到一个差异。

If you just want to see something like 'svn stat' you can use '--stat':

如果您只想查看类似“svn stat”的内容,可以使用“--stat”:

krausem-> git diff-tree f00e37882b7186e9e7f38c2fa28778e39734e2e7~1 f00e37882b7186e9e7f38c2fa28778e39734e2e7 --stat
 .../src/main/webapp/tiles/vertrag/freiKlauseln.jsp |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

回答by kaliatech

Second Answer(Revised after comments indicating --dry-run wasn't sufficient)

第二个答案(在表明 --dry-run 不够的评论后修改)

Depending on your expectations, it mightwork to use git log like this:

根据您的期望,像这样使用 git log可能会起作用:

git log remotes/svn.. --oneline

Note the two periods at end. That will show all commits on current branch since the last shared parent. In the case of typical git-svn usage, this would be all local commits since the last dcommit. (This assumes your remote SVN branch name is "remotes/svn". You can run "git branch -a" to list all branches.) It's important to understand what this is doing versus just running it verbatim, but perhaps this provides more of what you are looking for.

注意末尾的两个句点。这将显示自上次共享父级以来当前分支上的所有提交。在典型的 git-svn 用法的情况下,这将是自上次 dcommit 以来的所有本地提交。(这假设您的远程 SVN 分支名称是“remotes/svn”。您可以运行“git branch -a”来列出所有分支。)了解这是做什么而不是逐字运行很重要,但也许这提供了更多你在找什么。



First Answer

第一个答案

You can use --dry-run with dcommit:

您可以将 --dry-run 与 dcommit 一起使用:

git svn dcommit --dry-run

See this duplicate question/answer: How to see what has been checked into git, but hasn't been committed to svn via dcommit?.

请参阅这个重复的问题/答案:如何查看已检入 git,但尚未通过 dcommit 提交到 svn 的内容?.

回答by eckes

When I am in the situation of starting a git svn dcommit, I first open gitkand ask it to show me the commits to be transferred:

当我处于启动 a 的情况时git svn dcommit,我首先打开gitk并要求它显示要传输的提交:

gitk git-svn..

This assumes that your upstream SVN repo is really called git-svnas Tomasmentions. If you're unsure about the name of your upstream SVN repo, simply start gitkand search for a branch that you didn't create (and sounds Git-SVN-ish).

这假设您的上游 SVN 存储库确实被git-svn称为Tomas提到的。如果您不确定上游 SVN 存储库的名称,只需开始gitk并搜索不是您创建的分支(听起来像 Git-SVN 一样)。