简体   繁体   中英

How to commit to SVN and GIT in one commit?

Currently we're moving from SVN to GIT in my company.

We need to make both repositories the same for the coming few months, I need to have a command or an other way which commits my work for SVN and GIT.

I there such a way?

Yes, it is. Use git svn — it allows bidirectional manipulations between git and SVN.

You commit to git using git commit and then push commits to SVN using git svn dcommit .

If you gonna push commits from local git repo to some remotes first run dcommit because dcommit sends commits to SVN, creates SVN revisions and then rebases commits in git to synchronize git with SVN.

When someone else adds new commits to SVN you fetch them into git and rebase using git svn rebase .

Actually this does not make much sense, as you make many advantages of having a local Git repo of a remote SVN repo void this way. But if you really want to do this, just make an alias that does what you want. E. g. git config alias.committoboth '!ctb() { git commit "$@" && git svn dcommit; }; ctb' git config alias.committoboth '!ctb() { git commit "$@" && git svn dcommit; }; ctb' and then you can do stuff like git committoboth -m "my commit message" .

Instead you might also want to have a look at https://subgit.com/ . If you need to support Git and SVN for multiple users over a longer period, it might be better to do the synchronizing on the server which that tool says it does.

You cannot do it in one command unless you create a command to do it for you, as nativity git-svn does not have such command.

You can create an shell script file as git_svn which does groups all the command required by your workflow. And add this shell script to your system path:

#!/bin/sh
git commit -m "$1"
git push origin
git svn dcommit --rmdir

To use it, you wold just do:

$ git_svn "my commit message"

References:

  1. Git svn fetch and then commit to remote git
  2. https://gist.github.com/rickyah/7bc2de953ce42ba07116 A simple guide to git-svn

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM