今天想要合并两个分支的同一个文件,查了网上一些资料,将A分支的a文件合并到B分支的a文件上。可以通过以下方式合并
git checkout B
git checkout --patch A a
先切换到B分支,将A分支的a文件给与B。
然后碰到了Apply this hunk to index and worktree [y,n,q,a,d,/,K,j,J,g,e,?]?
刚开始我是一个一个y按得,后来觉得太慢也不敢乱按网上查询一下意思,在stackoverflow发现答案。
y - stage this hunk
n - do not stage this hunk
q - quit; do not stage this hunk nor any of the remaining ones
a - stage this hunk and all later hunks in the file
d - do not stage this hunk nor 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
k - leave this hunk undecided, see previous undecided hunk
K - leave this hunk undecided, see previous hunk
s - split the current hunk into smaller hunks
e - manually edit the current hunk
? - print help
上面这些文字都是输入?打印出来的。
Apply this hunk to index and worktree [y,n,q,a,d,/,K,j,J,g,e,?]??
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
? - 输出帮助信息
https://www.cnblogs.com/phpper/p/7609238.html
https://git-scm.com/book/zh/v2/Git-%E5%B7%A5%E5%85%B7-%E9%AB%98%E7%BA%A7%E5%90%88%E5%B9%B6