我创建了一个分支来尝试不同的方法并且它有效,所以我想将“Farmcrops”分支合并为“Master”以保持这些变化,但继续“Farmcrops”分支以探索另一种可能性。这样,如果这个最新的改变不起作用,我可以回到“大师”,现在包括第一轮的改变。
我该怎么做?
答案 0 :(得分:56)
如果我理解正确,您可以从
开始-- o -- o -- o [master]
\
o -- o [Farmcrops]
你不应该将Farmcrops
直接合并到master
,因为你冒着破坏master
中代码的风险,按惯例,这应该更加稳定。相反,请查看Farmcrops
并将master
合并到其中。
git checkout Farmcrops
git merge master
然后你会得到
-- o -- o -- o [master]
\ \
o -- o -- o [HEAD -> Farmcrops]
运行一些测试;确保一切按预期工作。然后查看master
并将Farmcrops
合并到其中:
git checkout master
git merge Farmcrops
您的回购将如下所示:
-- o -- o -- o
\ \
o -- o -- o [HEAD -> master,Farmcrops]
现在再次检查Farmcrops
并继续进行实验,对其进行更多提交等等......
-- o -- o -- o
\ \
o -- o -- o [master]
\
o -- o -- o [HEAD -> Farmcrops]
如果master
上的新实验没有“{1}},您可以随时使用Farmcrops
(现在包含"第一轮更改",正如您所说的那样)太好了。
答案 1 :(得分:26)
以下是您正在寻找的流程:
git checkout master
git merge Farmcrops
git push origin master
git branch -d Farmcrops
git checkout master
git checkout -b Farmcrops
Farmcrops
... 分支只是指针,创建/删除分支非常容易,如果没有将分支Farmcrops
推送到远程存储库,则绝对不会依赖它。您可以在合并后将其删除,然后从主服务器重新创建它。
希望这会对你有所帮助。
答案 2 :(得分:1)
在下面的链接中,解释了如何创建修补程序分支,进行更改并将其合并到主服务器。合并后仅删除差异,修补程序分支。
只需使用Farmcrops作为分支名称,并且在合并后不删除分支。
GIT-SCM: Basic Branching and Merging
[步骤1]创建分支并进行更改
$ git checkout Farmcrops
Switched to a new branch 'Farmcrops'
$ vim index.html
$ git commit -a -m 'fix the broken email address'
[Farmcrops 3a0874c] fix the broken email address
1 files changed, 1 deletion(-)
[步骤2]然后,返回主分支并合并
$ git checkout master
$ git merge Farmcrops
Updating f42c576..3a0874c
Fast-forward
README | 1 -
1 file changed, 1 deletion(-)
并且,如果您想在同一分支上进行更多更改,请再次应用[步骤1]。
完成更改后,再次应用[步骤2]。
根据需要执行以下步骤。
使用此分支完成工作后,您可以将其删除。
$ git branch -d Farmcrops
Deleted branch Farmcrops (was 3a0874c).
NOT:我建议使用rebase GIT-SCM: Rebase
而不是合并git rebase Farmcrops
答案 3 :(得分:0)
936 936 I ActivityTaskManager: START u0 {act=android.app.action.CONFIRM_DEVICE_CREDENTIAL_WITH_USER flg=0x8080000 pkg=com.android.settings cmp=com.android.settings/.password.ConfirmDeviceCredentialActivity$InternalActivity (has extras)} from
uid 1000
11-11 10:54:53.076 936 972 D ActivityTaskManager: Top Process State changed to PROCESS_STATE_TOP_SLEEPING
11-11 10:54:53.092 936 1032 W ProcessStats: Tracking association SourceState{2c15fa1 com.android.settings/1000 Top #565108} whose proc state 1 is better than process ProcessState{54a9784 com.google.android.gms.persistent/10029 pkg=com.google.android.gms} proc st
ate 2 (9 skipped)
11-11 10:54:53.126 936 936 D BiometricService: Creating auth session. Modality: 1, cookie: 1632337634
11-11 10:54:53.127 936 936 V FingerprintService: startAuthentication(com.android.settings)
11-11 10:54:53.128 936 936 V FingerprintService: Returning cookie: 1632337634
11-11 10:54:53.128 936 936 D BiometricService: Matched cookie: 1632337634, 0 remaining
11-11 10:54:53.128 936 936 V FingerprintService: starting client AuthenticationClientImpl(com.android.settings) cookie: 1632337634/1632337634
11-11 10:54:53.135 936 936 W FingerprintService: client com.android.settings is authenticating...
11-11 10:54:53.161 936 936 D BiometricService: Cancelling from CDC
11-11 10:54:53.162 936 936 V FingerprintService: Stopping client com.android.settings, fromClient: false
11-11 10:54:53.173 936 936 W FingerprintService: client com.android.settings is no longer authenticating
11-11 10:54:53.177 936 3056 D ActivityTaskManager: Top Process State changed to PROCESS_STATE_TOP
11-11 10:54:53.195 936 936 V FingerprintService: handleError(client=com.android.settings, error = 5)
11-11 10:54:53.195 936 936 V FingerprintService: Done with client: com.android.settings
11-11 10:54:53.196 936 936 D BiometricService: Error: 5 cookie: 1632337634
11-11 10:54:53.285 936 3041 I ActivityTaskManager: Activity reported stop, but no longer stopping: ActivityRecord{9b6d8b u0 com.natigbabayev.biometricprompt/.MainActivity t1936}
git branch -d feature-branch