0

I have a git checkout of an svn repository created via git svn clone. I have a complicated series of changes to my local git repository, which I am delaying pushing to the central svn repo. I would like to push a small change to one file. When using the svn client I would do

svn commit foobar.c

Is there a way to get similar functionality with git?

2 Answers 2

1

As long as you didn’t dcommit anything, you are totally able to use anything Git has to offer, including branching and rebasing things. So what you probably want to do is create a branch off the current SVN version (git branch <name> remotes/trunk) and work on that for now. Then you can dcommit those changes as you are used to.

To continue with your other changes then, you could rebase them to match the commits you pushed in between using git rebase remotes/trunk. Then you are back to a linear history with your later commit in between and continue working on your new features.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks. Is it the case in general that under practices I should only dcommit from the master branch? (or, at least, only from one branch, whether called 'master' or something else?)
To be honest, I never tried dcommit-ing from different branches myself. But based on how dcommit works, by commiting each diff separately and then rebasing the commits locally, I wouldn’t try to dcommit from a branch that is not based on the current svn trunk. I’d suspect it even won’t work (can’t try atm), but require you to git svn rebase first, to update the branch.
You can dcommit from any branch you want, it will work, but you can end up in a mess if you do not pay attention. But dcommit will work nicely, it is the git svn rebase part that needs proper handling. You can easily rebase the svn into any branch inside git, not only the master.
1

Easy.

Solution one: Anything uncommited inside git can be stashed away. No uncommitted files are allowed when dcommitting anyways.

Solution two: Start a new branch where you are now. Reset the master branch to the last commit you git from SVN. Commit the file to the master branch inside git. DCommit to SVN. Rebase the created new branch onto the new master after dcommit.

Any questions? Using a graphical tool will greatly help here...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.