美文网首页
git 怎样将分支上的一个单文件合并到主分支上(master)

git 怎样将分支上的一个单文件合并到主分支上(master)

作者: 龙之天下 | 来源:发表于2022-03-30 20:33 被阅读0次

    1、首先切换到主分支 注意将分支上的数据全部提交 以免造成数据冲突或丢失

    git checkeout master
    

    2、选择要合并的文件

    git checkout --patch 分支名称  要合并的文件路径
    
    PS:git checkout --patch dev  xxxx/ErrorView.swift
    

    3、此时文件将合并完成 最重要的一步一定是 提交

    git add -A 文件路径
    git commit -m '注释'
    git push
    如果不想合并只是测试  一定要回滚回来
    git reset --hard origin/master 到上一个版本
    

    附录:git 小知识

    y - apply this hunk to index and worktree
    n - do not apply this hunk to index and worktree
    q - quit; do not apply this hunk or any of the remaining ones
    a - apply this hunk and all later hunks in the file
    d - do not apply this hunk or any of the later hunks in the file
    g - select a hunk to go to
    / - search for a hunk matching the given regex
    j - leave this hunk undecided, see next undecided hunk
    J - leave this hunk undecided, see next hunk
    e - manually edit the current hunk
    ? - print help
    
    y - 存储这个hunk
    n - 不存储这个hunk
    q - 离开,不存储这个hunk和其他hunk
    a - 存储这个hunk和这个文件后面的hunk
    d - 不存储这个hunk和这个文件后面的hunk
    g - 选择一个hunk
    / - 通过正则查找hunk
    j - 不确定是否存储这个hunk,看下一个不确定的hunk
    J - 不确定是否存储这个hunk,看下一个hunk
    k - 不确定是否存储这个hunk,看上一个不确定的hunk
    K -不确定是否存储这个hunk,看上一个hunk
    s - 把当前的hunk分成更小的hunks
    e - 手动编辑当前的hunk
    ? - 输出帮助信息
    

    相关文章

      网友评论

          本文标题:git 怎样将分支上的一个单文件合并到主分支上(master)

          本文链接:https://www.haomeiwen.com/subject/jdmwjrtx.html