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.