Git无法合并两个分支中没有差异的文件

时间:2018-02-24 10:02:50

标签: git

我正在将一个分支与另一个分支合并,我总是有冲突:

bicou@mba ~/AndroidStudioProjects/xxx (master) $ git status
On branch master
Your branch is ahead of 'origin/master' by 30 commits.
  (use "git push" to publish your local commits)

You have unmerged paths.
  (fix conflicts and run "git commit")
  (use "git merge --abort" to abort the merge)

Changes to be committed:

    modified:   alpha.sh

Unmerged paths:
  (use "git add <file>..." to mark resolution)

    both modified:   app/src/main/res/values-fr/strings.xml

显然strings.xml无法自动合并。但是没有区别:唯一没有合并的东西是文件的底部:

bicou@mba ~/AndroidStudioProjects/xxx (master) $ tail -5 app/src/main/res/values-fr/strings.xml
<<<<<<< HEAD
</resources>
=======
</resources>
>>>>>>> develop

让我们回顾一下hexa(空白等)中的两行:

bicou@mba ~/AndroidStudioProjects/xxx (master) $ tail -5 app/src/main/res/values-fr/strings.xml | tail -2 | head -1 | xxd
00000000: 3c2f 7265 736f 7572 6365 733e 0a         </resources>.

bicou@mba ~/AndroidStudioProjects/xxx (master) $ tail -5 app/src/main/res/values-fr/strings.xml | head -2 | tail -1 | xxd
00000000: 3c2f 7265 736f 7572 6365 733e 0a         </resources>.

没有区别。为什么git不能自动合并?

编辑:尽管如此,它似乎是一个空白问题,但我不明白为什么它没有在合并文件中声明,只有在手动区分文件时才会说明:

bicou@mba ~/AndroidStudioProjects/xxx (master) $ git diff develop -- app/src/main/res/values-fr/strings.xml
diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml
index 5804034..2097f87 100644
--- a/app/src/main/res/values-fr/strings.xml
+++ b/app/src/main/res/values-fr/strings.xml
@@ -96,4 +96,4 @@
     <string name="fragment_min_max_set_button">Valider</string>
     <string name="fragment_min_max_clear_button">Effacer</string>
     <string name="drawer_name_no_account">Invité</string>
-</resources>
\ No newline at end of file
+</resources>

注意:这不是Windows / Unix终端问题。我根本不使用Windows,只使用LF。问题可能来自我的编辑器,该编辑器未在文件末尾添加新行字符。这是根本问题。

1 个答案:

答案 0 :(得分:1)

尽管如此,它似乎是一个空白问题,但我不明白为什么它在合并文件中没有说明,只有在手动区分文件时才会说明:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Registration | Badhon</title>
<link rel="stylesheet" type="text/css" href="registration.css">
</head>


<body background="images/registration.jpg">



	<div class="title">
		<h1>Registration</h1>
	</div>

	<div class="container">

		<div class="left">
       <div><h1>Choose an image (300*300)</h1></div>
   
   
   /* First Form tag ---------------------*/
      <form name="fileform" method="post" action="uploadImage" enctype="multipart/form-data">
				
				<br> <label for="photo"> Portrait Photo: </label> <input
					type="file" name="photo" size="50" placeholder="Upload Your Image"
					required /><br>
				<br> <input type="submit" value="Save">
			</form>
      
 
 /* End of First Form Tag---------------------*/
	 
   
   </div>


		<div class="right">
			<div class="formbox">
				
  /* Second Form tag------------------ */      
        <form action="DonarRegister">
					<p>Name</p>
					<input type="text" name="name" placeholder="Name">
					
					<p>Username</p>
					<input type="text" name="username" placeholder="User_name">
					
					<p>Password</p>
					<input type="Password" name="password" placeholder="..........">
					
					<p>Blood Group</p>
					<input type="text" name="bloodgroup" placeholder="O positive">
					
					<p>Age</p>
					<input type="number" name="age">
					
					<p>Mobile Number</p>
					<input type="text" name="mobilenumber" placeholder="......">
					
					<p>email</p>
					<input type="text" name="email" placeholder="......">
					
					<p>Address</p>
					<input type="text" name="address" placeholder="Village/Thana/District"> 
					<input type="submit" name="" value="Register">
				    
				   <p> <h5>Have already an account !! Then <a href="login.jsp">just login</a></h5></p>



</form>
/* End of Second form tag ----------------- */ 
 
 
			</div>
		</div>
	</div>
</body>
</html>