commit是直接提交到远程吗 svn_git svn获取并提交到远程git

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.

Currently I'm using:

git svn fetch

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"

returns:

Your branch is up-to-date with xxx

nothing to commit, working directory clean

Clearly something changed but my git won't notice.

What am I missing?

解决方案

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

Background

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

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 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

Here's what the documentation has to say about it:

You can run git svn fetch to grab the new data, but git svn rebase

does the fetch and then updates your local commits.

Keep in mind that you shouldn't have any modified files in your working directory when you run 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.

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

git push origin

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值