How to merge branch with trunk using SVN in android studio

后端 未结 3 2151
轮回少年
轮回少年 2021-02-08 19:31

I would like to commit my changes in the branch and add those changes to the trunk version using the built-in svn tool in Android Studio. How can I do it?

Should I expec

相关标签:
3条回答
  • 2021-02-08 20:01

    As it says on this link of IntelliJ Doc (Android Studio and the Android plugin for IntelliJ IDEA are built from the same code)

    To merge branch changes back into trunk, you should open trunk working copy and do same steps as when taking changes from trunk into branch (selecting source branch in popup). Additionally, you will be warned:

    Merge information gathering rules To be able to merge changes back to trunk in a bunch (using Subversion “--reintegrate”), you should NOT have any merges done on other target that working copy root, i.e. you should not have any svn:mergeinfo properties set in working copy subtree. That’s why when checking what revisions are merge, by default, IntelliJ IDEA would not check merge information in a subtree. But if you somewhy need subtree to be checked, you should go to “Settings | Version Control | VCSs | Subversion” and set “Check svn:mergeinfo in target subtree when preparing for merge”.

    More info and full doc can be located at: https://devnet.jetbrains.com/docs/DOC-1203

    Edit:

    Answering to Error: svn: E195016: Merge tracking not allowed with missing subtrees:

    That error occurs when someone deletes something without using Subversion commands. If you were to run svn status on that working copy the same path that Subversion is complaining about should show with a ! in the first column of the output. Try using svn rm instead of OS commands.

    0 讨论(0)
  • 2021-02-08 20:13

    5 years later...

    I am using Android Studio 3.1.5 and SVN.

    To merge back a branch to its trunk:

    1. Switch to the trunk. In TortoiseSVN, it is easy to switch. Right click on your working copy -> TortoiseSVN -> Switch.
    2. You should see a dialog window like below. In To Path field, make sure that it points to your trunk folder. In Revision field, I always choose HEAD revision so I transfer everything from the branch to trunk. Click OK.

    1. In Android Studio (AS), make sure that the switch worked. To verify, go to the task bar at the bottom of your AS. Click Version Control -> Subversion Working Copies Information -> Refresh. See if URL field points to your trunk.

    1. Start the merging. Click Version Control -> Subversion Working Copies Information -> Merge From.... In the small pop-up window, select the branch you want to merge to trunk. It may also ask for which directory or file in the said branch you want to merge. Make the appropriate selection.
    2. In Select Merge Variant window, most of the time I select Merge All because that is usually the goal. Click OK.

    1. Finally commit the newly merged changes.

    NOTE: I prefer merging the trunk to my branch first. Resolve the conflicts in the branch, then finally, merge back to trunk.

    0 讨论(0)
  • 2021-02-08 20:22

    How to create SVN branch directly in AS

    1. Download SVN plugin from File -> Settings -> plugins -> Marketplace -> "Subversion"
    2. Enable VCS in VCS tab if not already enabled
    3. VCS -> Browse VCS repository -> Browns SVN repository
    4. Right click the folder/repo you want to branch, click "Branch or Tag..."
    5. Select parent folder so that repos become siblings (or as you wish)
    6. Name the folder with ending -your-feature (or as you wish)
    7. Checkout your newly created branch
    8. Run to check if the branch works fine on its own (on linux/ios "chmod a+rx android/gradlew" might be necessary)
    9. Your commits will now only be to the current branch

    How to merge SVN branch back to trunk/main repo

    1. Go back to your trunk/main repo (or check it out if you haven't already)
    2. VCS -> "Integrate project..."
    3. Change "Source 2" to the branch you want to merge from
    4. Resolve conflicts if any
    5. Commit changes to trunk

    SVN switch branches

    • Can be done using VCS -> "Update project..." -> Update/switch to another branch
    • Or better still can be to just have one main/trunk project and one branch project

    Reference

    I personally did it slightly different than the official docs. But basically making a branch is just copying the folder as I understand it. Merging on the other hand seems a little more complicated, as every reference of change has to be present. For instance deleting or moving a folder has to be a committed change, it can not just be done without a reference in SVN.

    Also their way is to keep the main folders current name but making some subfolders name indicating that it is a branch.

    • SVN intellij branching
    • SVN intellij merging
    0 讨论(0)
提交回复
热议问题