2016-07-22 118 views
1

我标志着一个本地文件不变通过更新索引,使用假设本地文件后合并:Git的 - 无法更新索引不变

git update-index --assume-unchanged <file1> 

虽然,file1存在于远程仓库。现在,当我试图通过合并远程分支:

git checkout myBranch 
git merge origin/myRemoteBranch 

我得到它说的错误:

error: Your local changes to the following files would be overwritten by merge: 
     file1 
Please commit your changes or stash them before you can merge. 
Aborting 

我不能提交或藏匿任何东西,因为git status说:“没什么可提交”标记为file1assume-unchanged。如何将远程分支合并到本地分支并保持file1的本地更改未被跟踪。

回答

0

当您将其他分支合并到本地分支时,其他分支(远程或不远程)不会发生更改。

我假设你有一个文件,它已经存在于远程分支上,并且不希望git跟踪对该文件的额外更改。如果是这种情况,您应该创建.gitignore文件并在其中添加file1。 阅读:https://git-scm.com/docs/gitignore

+0

这听起来像是一个解决方案,但是当我更新我的分支上的'.gitignore'后来最终被合并到'master'时,我不希望'master1'上的'file1'被忽略。为了更清晰地编辑我的问题。 – shubhamsingh