SVN 创建分支

2种方法:

创建分支之前一定要先更新到最新版本。

1.你用tortoiseSVN点版本库浏览,在需要建立分支的路径(比如trunk)点copy to + 新分支名称(注意:必须与trunk不能同名,你可以新建一个名称比如branch),然后在分支文件夹的根目录update。

2.tortoiseSVN点版本库浏览,你在需要创建的路径下右键tortoiseSVN 选择create folder 然后创建新路径名称(文件夹)然后把主干或者其他分支路径的代码(拉分支这种情况估计想并行开发)导入到这个路径下就可以了,然后在分支文件夹的根目录update。

创建分支是否成功,在分支文件夹里面 TortoiseSVN  ---->版本库浏览器  定位的是分支路径那就对了,如果还是主干路径那创建分支就有问题了。

注意:1、如果分支目录在没有分支的情况下check out下来的项目,这时候工作副本对应版本库的路径仍为原来对应的主干的目录。所以在客户端文本夹中删除之后 再从服务器Update分支的项目。不能用客户端SVN delete,这样会删除主干上的项目。


2、如果是多个项目,只保留几个项目做分支,那就从版本浏览器中分支的项目右键删除,不能从本地svn delete,这样会删除主干上的项目。


修改相关文件项目名,这样就能引入eclipse 了

/gjmj/mallv2/branchs/gjmj_20141110/shop/.classpath
/gjmj/mallv2/branchs/gjmj_20141110/shop/.project
/gjmj/mallv2/branchs/gjmj_20141110/shop/WebRoot/WEB-INF/web.xml
/gjmj/mallv2/branchs/gjmj_20141110/shop/config/boot.xml
/gjmj/mallv2/branchs/gjmj_20141110/shop/config/ui/path.xml


下面修改相关文件项目名的代码根据具体需要改动

import java.io.BufferedReader;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;


/**
 * 1、修改多个项目的路径,以便导入eclipse
 * 2、全部替换gjmj_20141110为分支文件夹
 * @author Coco
 *
 */
public class FileContentReplace {
 private static String REPLACE_SRC_FILE = "E:\\workspaces\\gjmj\\mallv2\\branchs\\gjmj_20141110";
 private static String REPLACE_EXCLUDE_FILE = "E:\\Workspaces\\gjmj\\mallv2\\branchs\\gjmj_20141110\\core\\WebRoot\\sr;E:\\Workspaces\\gjmj\\mallv2\\branchs\\gjmj_20141110\\core\\WebRoot\\upload;E:\\Workspaces\\gjmj\\mallv2\\branchs\\gjmj_20141110\\core\\WebRoot\\WEB-INF\\lib;toruk.xml";
 
 private static String REPLACE_CONTENT = "gjmj_mallv2->gjmj_20141110;E:/Workspaces/gjmj/mallv2/project/->E:/Workspaces/gjmj/mallv2/branchs/gjmj_20141110/;E:/workspaces/gjmj/mallv2/project/->E:/workspaces/gjmj/mallv2/branchs/gjmj_20141110/";
 
 public static List<String> EXCLUDE_FILE_LIST = null;
 
 public static Map<String,String> getReplaceMaping()  {
   Map<String,String> map = new HashMap<String,String>();
   if(REPLACE_CONTENT!=null){
     String[] repContentArr = REPLACE_CONTENT.split(";");
     for(String repMap:repContentArr){
       String[] arg = repMap.split("->");
       if(arg.length!=2){
         throw new RuntimeException(repMap+"不正确");
       }else{
         map.put(arg[0], arg[1]);
       }
     }
   }
   return map;
 }
 
 public static List<String> excludeFileList(){
   if(EXCLUDE_FILE_LIST==null){
     EXCLUDE_FILE_LIST = new ArrayList<String>();
     if(REPLACE_EXCLUDE_FILE!=null){
       String[] strArr = REPLACE_EXCLUDE_FILE.split(";");
       for(String str:strArr){
         EXCLUDE_FILE_LIST.add(str.trim());
       }
     }
     return EXCLUDE_FILE_LIST;
   }else{
    return EXCLUDE_FILE_LIST;
   }
 }
 public static void handFile(File infile,String fromCharSet,String toCharSet) throws Exception{
      if(infile.getName().equals(".svn")){
        return;
      }
      if(infile.getName().contains("!")){
        return;
      }
      for(String excludeFile:excludeFileList()){
        if(infile.getPath().toLowerCase().contains(excludeFile.toLowerCase())||infile.getName().equals(excludeFile)){
          return;
        }
      }
      
      BufferedReader in = new BufferedReader(new InputStreamReader(
      new FileInputStream(infile), fromCharSet));
      String reading;
      String  content = "";
      while ((reading = in.readLine()) != null) {
        content +=reading+"\r\n";
      }
      boolean flag = false;
      Map<String,String> replaceMapping = getReplaceMaping();
      if(replaceMapping!=null){
        Set<Map.Entry<String, String>> replaceEntrys =   replaceMapping.entrySet();
        for(Iterator<Map.Entry<String, String>> it = replaceEntrys.iterator();it.hasNext();){
          Map.Entry<String, String> entry = it.next();
          String key = entry.getKey();
          if(content.contains(key)){
            flag = true;
          }
        }
      }
      
      if(flag){
        File outfile = new File(infile + ".tmp");
        PrintWriter out = new PrintWriter(new BufferedWriter(
        new OutputStreamWriter(new FileOutputStream(outfile), toCharSet)));
        
        if(replaceMapping!=null){
          Set<Map.Entry<String, String>> replaceEntrys =   replaceMapping.entrySet();
          for(Iterator<Map.Entry<String, String>> it = replaceEntrys.iterator();it.hasNext();){
            Map.Entry<String, String> entry = it.next();
            String key = entry.getKey();
            String value = entry.getValue();
            content = content.replaceAll(key, value);
          }
          System.out.println("替换文件:"+infile.getPath());
        }
        
        out.println(content);
        out.flush();
        out.close();
        in.close();
        infile.delete();
        outfile.renameTo(infile);
      }else{
        in.close();
      }
      
    
  }
 
 
 
  public static void main(String[] args) throws Exception {
     replaceFile(new File(REPLACE_SRC_FILE),"UTF-8","UTF-8");
  }


  public static void replaceFile(File filePath,String fromCharSet,String toCharSet) throws Exception{
    if(filePath.exists()==false){
      new RuntimeException(filePath.getPath()+"不存在");
    }
    
    if(filePath.getName().equals(".svn")){
      return;
    }
    for(String excludeFile:excludeFileList()){
      if(filePath.getPath().toLowerCase().contains(excludeFile.toLowerCase())){
        return;
      }
    }
    
    if(filePath.isDirectory()){
      File[] childFiles = filePath.listFiles();
      if(childFiles!=null){
        for(File childFile:childFiles){
          if(childFile.isFile()){
            handFile(childFile,fromCharSet, toCharSet);
          }else{
            replaceFile(childFile,fromCharSet, toCharSet);
          }
        }
      }
    }else{
      handFile(filePath,fromCharSet, toCharSet);
    }
  }
}


要在IDEA中使用SVN创建分支,你可以按照以下步骤进行操作: 1. 首先,从SVN拉取trunk分支的代码。这是生产版本的代码,所以我们最好不要直接在trunk分支上修改。 2. 在IDEA中,选择菜单栏中的VCS(版本控制系统)选项,然后选择Git或者SVN,具体取决于你使用的版本控制系统。 3. 在版本控制系统的选项中,选择Copy From。 4. 在Copy From的选项中,你有两个选择: - 第一个选项是直接复制你当前本地的代码来创建新的branch分支。 - 第二个选项是从SVN服务器中选择代码来创建新的branch分支。你可以选择从trunk上的代码来创建branch分支,或者选择SVN服务器上已有的branch代码来创建新的branch分支。 5. 创建成功后,你需要将当前编辑的分支切换到刚刚创建的branch分支。右键点击你的项目名称,选择subversion,然后选择update directory。勾选"Update/Switch to specific url",然后重新设置新的URL即可切换到SVN分支。 通过这些步骤,你就可以在IDEA中使用SVN创建分支了。记住,在开发过程中,最好在branch分支上进行修改,等到开发完成并通过测试后,再将写好的branch分支合并到trunk分支中。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [【IDEA】如何在IDEA中创建SVN项目分支](https://blog.csdn.net/cy973071263/article/details/119539866)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值