git svn获取并提交到远程git [英] Git svn fetch and then commit to remote git

查看:133
本文介绍了git svn获取并提交到远程git的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的客户有一个SVN存储库,我想改用git.我用git-svn从客户的svn中创建了一个git,并为其创建了一个gitlab.如果我的客户改变了他的东西,我想获取这些改变,然后更新我的gitlab以使所有内容保持同步.

My customer has a SVN repo and I would like to use git on my side instead. I used git-svn to create a git from my customer's svn and created a gitlab for it. If my customer changes something on his side I would like to fetch the changes and then update my gitlab to keep everything in sync.

当前我正在使用:

git svn fetch 

如果更改了某些内容,我会进行一些更改.收到更改后,我仍然无法将所述更改推送到我的git.

And if something was changed, I get a few changes. After receiving the changes I am still not able to push said changes to my git.

git commit -am "Changed something"

返回:

您的分支机构的最新信息是xxx

Your branch is up-to-date with xxx

什么都不提交,工作目录很干净

nothing to commit, working directory clean

很明显有些变化,但是我的git没注意到. 我想念什么?

Clearly something changed but my git won't notice. What am I missing?

推荐答案

tl; dr

如果要使您的GitLab存储库与Subversion 1保持同步,则应运行以下命令:

tl;dr

If you want to keep your GitLab repository in sync with the Subversion one, you should run these commands:

# Fetch the latest commits from SVN and merge them into the current branch
git svn rebase

# Push the new commits to GitLab
git push origin

背景

从逻辑上讲,当您运行git svn fetch时,您将从SVN存储库中收到新的 commits -而不是文件.

Background

Logically speaking, when you run git svn fetch you're receiving new commits from the SVN repository – not files.

这就是为什么当您尝试创建新的提交时收到错误消息的原因:Git告诉您工作目录中没有任何已修改的文件.

That's why you're getting that error message when you try to create a new commit: Git is telling you that you don't have any modified files in your working directory.

git svn fetch会将新的提交下载到您的存储库中,但不会自动将它们合并到当前分支中.为此,您应该运行:

git svn fetch will download the new commits into your repository but it won't automatically merge them into the current branch. To do that, you should run:

git svn rebase

这是文档不得不说:

您可以运行git svn fetch来获取新数据,但是git svn rebase 进行提取,然后更新您的本地提交.

You can run git svn fetch to grab the new data, but git svn rebase does the fetch and then updates your local commits.

请记住,运行git svn rebase时,工作目录中不应包含任何已修改的文件:

Keep in mind that you shouldn't have any modified files in your working directory when you run git svn rebase:

运行此文件时,您需要确保您的工作目录是干净的, 尽管.如果您进行了本地更改,则必须隐藏您的工作或 在运行git svn rebase之前临时提交它-否则, 如果看到变基将导致合并,则命令将停止 冲突.

You need to be sure your working directory is clean when you run this, though. If you have local changes, you must either stash your work or temporarily commit it before running git svn rebase — otherwise, the command will stop if it sees that the rebase will result in a merge conflict.

在提取并合并提交后,您可以通过以下方式将它们发布到您的GitLab存储库中:

After the commits have been fetched and merged, you can publish them to your GitLab repository by saying:

git push origin

其中origin是指向GitLab存储库的远程名称.

where origin is the name of the remote that points to the GitLab repository.

这篇关于git svn获取并提交到远程git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆