相关疑难解决方法(0)

如何git-cherry-pick仅更改某些文件?

如果我想要合并到Git分支中,那么只对某个特定提交中更改的某些文件进行了更改,其中包括对多个文件的更改,如何实现?

假设git的承诺称为stuff具有对文件的改变A,B,C,和D,但我想只合并stuff的对文件的更改AB.这听起来像是一项工作,git cherry-pickcherry-pick只知道如何合并整个提交,而不是文件的子集.

git github cherry-pick

525
推荐指数
12
解决办法
20万
查看次数

Git:如何为合并创建补丁?

当我使用时git format-patch,它似乎不包括合并.如何执行合并,然后将其作为一组补丁通过电子邮件发送给某人?

例如,假设我合并了两个分支并在合并之上执行另一个提交:

git init

echo "initial file" > test.txt
git add test.txt
git commit -m "Commit A"

git checkout -b foo master
echo "foo" > test.txt
git commit -a -m "Commit B"

git checkout -b bar master
echo "bar" > test.txt
git commit -a -m "Commit C"

git merge foo
echo "foobar" > test.txt
git commit -a -m "Commit M"

echo "2nd line" >> test.txt
git commit -a -m "Commit D"
Run Code Online (Sandbox Code Playgroud)

这将创建以下树:

    B
  /   \
A       M …
Run Code Online (Sandbox Code Playgroud)

git merge patch

27
推荐指数
4
解决办法
2万
查看次数

标签 统计

git ×2

cherry-pick ×1

github ×1

merge ×1

patch ×1