我在 Git 存盤庫中有兩個分支。
* 68d0cfc (HEAD -> master) Fixed error in makefile. Command rm is now erasing main.o, too.
| * a2dcb6c (temp_branch) Temporary commit to save progress.
|/
* c86fd55 structs trans_table_entry and trans_table created. Functions get_trans_table_available_entry, create_insert_new_trans_entry and compare_input_with_trans_key defined.
* b8ba145 structs fsm_t and state_t created. Functions create_fsm, create_new_state and set_fsm_initial_state defined
在每個分支中都有一個包含不同內容的 main.c。
這是來自 master 分支的 main.c。
#include <stdio.h>
#include <stdlib.h>
#include "fsm.h"
int main(void) {
fsm_t *fsm = create_fsm("fsm0");
state_t *q0 = create_new_state("q0", false);
state_t *q1 = create_new_state("q1", false);
set_fsm_initial_state(fsm, q0);
printf("FSM %s\n", fsm->fsm_name);
printf("State %s\n", q0->state_name);
printf("State %s\n", q1->state_name);
printf("FSM initial state %s\n", fsm->initial_state->state_name);
trans_table_entry_t *trans_table_entry = create_insert_new_trans_entry(q0, "01", q1);
printf("New trans_table_entry: \n");
printf(" transition_key: %s\n", trans_table_entry->transition_key);
printf(" next_state: %s\n", trans_table_entry->next_state->state_name);
printf("trans_table_entry in fsm0's initial state: \n");
printf(" transition_key: %s\n", STATE_ENTRY_TR_KEY(fsm->initial_state, 0));
printf(" next_state: %s\n", STATE_ENTRY_NEXT_STATE(fsm->initial_state, 0)->state_name);
char trans_key1[] = "0111";
char trans_key2[] = "0X10";
char *input = "01110010";
printf("Comparing trans_key1(%s) with 0111: %s\n", trans_key1, compare_input_with_trans_key(input, trans_key1) == true? "Valid" : "Invalid");
printf("Comparing trans_key2(%s) with 0111: %s\n", trans_key2, compare_input_with_trans_key(input, trans_key2) == true? "Valid" : "Invalid");
input = 4;
printf("Comparing trans_key1(%s) with 0010: %s\n", trans_key1, compare_input_with_trans_key(input, trans_key1) == true? "Valid" : "Invalid");
printf("Comparing trans_key2(%s) with 0010: %s\n", trans_key2, compare_input_with_trans_key(input, trans_key2) == true? "Valid" : "Invalid");
return 0;
}
這主要來自 temp_branch。
#include <stdio.h>
#include <stdlib.h>
#include "fsm.h"
int main(void) {
fsm_t *fsm = create_fsm("0s_1s_alt");
//Initial state. No data.
state_t *q0 = create_new_state("q0", false);
//Last bit received is 1. Second last is 0.
state_t *q1 = create_new_state("q1", false);
//Last bit received is 0. Second last is 1.
state_t *q2 = create_new_state("q2", false);
//Dead state.
state_t *D = create_new_state("D", true);
set_fsm_initial_state(fsm, q0);
char *trans_key = "0";
trans_table_entry_t *trans_table_entry = create_insert_new_trans_entry(q0, trans_key, q2);
trans_key = "1";
trans_table_entry = create_insert_new_trans_entry(q0, trans_key, q1);
trans_key = "0";
trans_table_entry = create_insert_new_trans_entry(q1, trans_key, q2);
trans_key = "1";
trans_table_entry = create_insert_new_trans_entry(q1, trans_key, D);
trans_key = "0";
trans_table_entry = create_insert_new_trans_entry(q2, trans_key, D);
trans_key = "1";
trans_table_entry = create_insert_new_trans_entry(q2, trans_key, q1);
trans_key = "0";
trans_table_entry = create_insert_new_trans_entry(D, trans_key, D);
trans_key = "1";
trans_table_entry = create_insert_new_trans_entry(D, trans_key, D);
char input[] = {'0', '1', '0', '1', '0', '1', '1', '0'};
if(execute_fsm(fsm, input) == FSM_NO_ERROR) {
printf("%s working correctly.\n", fsm->fsm_name);
}
else {
printf("An error occurred. One of the transitions was not executed.\n");
}
return 0;
}
我已經嘗試過使用不同的方法
git merge temp_branch
git merge -s resolve master temp_branch
這是我合并后得到的。
Merge made by the 'ort' strategy
fsm.c | 25
fsm.h | 4 --
main.c | 57 --------------------------
3 files changed, 58 insertions( ), 28 deletions(-)
Trying really trivial in-index merge...
fsm.c | 25
fsm.h | 4 --
main.c | 57 --------------------------
3 files changed, 58 insertions( ), 28 deletions(-)
但結果總是一樣的:Git 一直用 temp_branch 中的內容替換 main.c 中的內容,沒有任何錯誤。如果兩個檔案的內容不同,為什么會出現這種情況?
uj5u.com熱心網友回復:
只有當 main.c 時才會有沖突:
temp_branch自創建以來,兩個分支都已更改- 如果在公共線路上進行了更改
如果不是,則從temp_branch報告到 的更改master。
在每個分支中都有一個包含不同內容的 main.c。
main.c如果/中的“不同內容”是在修改之前master完成的,那么合并到 master 只會將這些修改報告回. temp_branchtemp_branchtemp_branchmaster
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/488187.html
上一篇:如何更改分支并從另一個分支拉取?
下一篇:Gitpullerrorclient_loop:senddisconnect:ConnectionresetbypeeriB/s
