Git-svn: create & push a new branch/tag?

后端 未结 3 1931
心在旅途
心在旅途 2020-12-04 07:16

After cloning an SVN repository using git-svn with the -s option (git svn clone http://server/repo -s), how does one create a branch or tag and hav

3条回答
  •  情深已故
    2020-12-04 07:26

    If you created your local branch before the subversion branch existed and you now want to push your local branch into a subversion branch, you can do the following:

    Obtain the svn branch revision assigned to the local branch

    $ git svn info

    from the output, URL field would be the current svn branch path and Revision field would be the subversion revision number

    Create the svn branch from the revision that you created your local branch

    $ svn cp http://svn-repo/my_app/trunk@123 http://svn-repo/my_app/branches/feature1

    Fetch the new svn branch so that your git repo knows about it

    $ git svn fetch

    The svn branch should now be added as a remote in your git repo $ git branch -a * feature1 master remotes/feature1

    At this point your remote will still be trunk. You need to point your local branch to the new remote branch. You can do this by rebasing your local branch from the remote branch: $ git rebase remotes/feature1

    Now that your local branch refer to your remote branch, you can commit your changes onto it. First do a dry run so you are confident that your changes will go into your remote branch: $ git svn dcommit --dry-run Commiting to http://svn-repo/my_app/branches/feature1

    Now you may commit changes to your remote branch $ git svn dcommit

    Most how-tos will tell you to branch subversion first and then create a local branch which tracks the remote branch. But I often don't decide ahead of time whether my local branch should track a remote branch. Often I branch locally, and make changes without any intention of pushing to a remote branch. If I later decide to commit my local branch into a remote branch I perform the steps above.

提交回复
热议问题