简体   繁体   中英

How to sync between multiple branches in git

I have three branch master,child_1,child_2 in git. All branches have ABC.txt file,master branch's ABC.txt file contains ABCDE,12345 , child_1 ABC.txt file contains ABCDE and child_2 ABC.txt file contains 12345 .If I changes ABCDE into abcde in branch child_1's ABC.txt file, then my master text also changes from ABCDE 12345 to abcde 12345 .

Please help me. Thanks!

Note: I am using windows machine.

EDIT: I am assuming you expect the file content from ABC.txt on branch master to be "ABCDE 12345" instead of "abcde 12345" and that that is your problem (as it is not clearly stated in your question)

I think there are two possible explanations:
1. The contents of your ABC.txt on branch master were "abcde 12345" from the beginning and not "ABCDE 12345" (so you accidently forgot to capitalize the letters);
2. Your installation of Git is broken.

Case 1
To check if it is case 1, run in your git directory:

git checkout master
git log

You will get an output like illustrated in Fig. 1 .

git日志

Look up the commit where you added the ABC.txt file and its content. Copy the hash (highlighted in Fig. 1 ) and checkout that commit.

git checkout <insert hash here>

Now, browse to your ABC.txt file and open it. You will probably see that the contents of the file are "abcde 12345".

Case 2
If case 1 is not the case, check if Git properly installed. I do not know how to validate the installation of Git on Windows, but it will not hurt to reinstall Git and try to reproduce your problem.

Side note: I did use Ubuntu 18.04 with Git version 2.17.1 and not Git on Windows

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM