【发布时间】:2019-12-02 21:05:37
【问题描述】:
我想根据我的本地代码和远程源代码之间的差异创建一个补丁。
我这样做:
git diff origin/myTestBranch > myPatch.patch
我进入一个单独的目录,该目录克隆了相同的 repo 并刚刚拉取了 myTestBranch。我这样做是用
cd testPatchRepo
git clone ....
git checkout myTestBranch
当我尝试应用补丁时 - 它失败了!
但是,如果我提交我的工作并使用 git diff firstCommit ^...lastCommit > myPatch.patch 创建补丁 补丁应用没有问题...这并不能解决我的问题,因为我仍然希望能够从我的本地、未提交的工作中创建补丁。
这是从本地未提交的工作中创建的补丁:
diff --git a/scripts b/scripts
index 8640468..adfabd7 160000
--- a/scripts
+++ b/scripts
@@ -1 +1 @@
-Subproject commit 8640468cc4ba87bebee0e9e26939361bcb3e3afa
+Subproject commit adfabd7bf11566f2888a4501bc557265f1172ac2-dirty
diff --git a/source/tutorial/install.txt b/source/tutorial/install.txt
index 5fee5f6..5ef6e4b 100644
--- a/source/tutorial/install.txt
+++ b/source/tutorial/install.txt
@@ -16,7 +16,7 @@ Install {+bi-short+} on Windows
.. include:: /includes/fact-bi-enterprise.rst
-Massaddie
+Maaaaassaddie
To set up |bi|,
follow the steps on this page.
提交我的更改后创建的补丁:
commit 983393a03262f8dccfd90b3c948751846ae583ae
Author: maddie <myemail>
Date: Mon Dec 2 17:17:42 2019 -0500
commit before make stage commit
diff --git a/source/tutorial/install.txt b/source/tutorial/install.txt
index 5fee5f6..5ef6e4b 100644
--- a/source/tutorial/install.txt
+++ b/source/tutorial/install.txt
@@ -16,7 +16,7 @@ Install {+bi-short+} on Windows
.. include:: /includes/fact-bi-enterprise.rst
-Massaddie
+Maaaaassaddie
To set up |bi| with a business intelligence tool such as Tableau,
follow the steps on this page.
【问题讨论】:
-
在创建补丁之前运行
git pull --rebase origin ...(...需要替换为远程分支名称)。另外,您真的有一个名为 myTestBranch 的远程分支吗?你是如何克隆并切换到它的? -
它实际上被称为 test2,但为了这篇文章的目的,我给它起了一个更好的名字。我 fork 一个 repo,克隆它并使用
git checkout test2切换到分支 -
我希望能够对我在本地拥有的任何东西进行 git diff - 甚至是未提交的工作。
git pull --rebase origin/....要求提交或隐藏我的所有更改 -
我的意思是你的基础和克隆的 repo 上的不一样。
-
在做
git pull --rebase之前有没有办法验证它们的碱基不同?