Problems with merging after a git update-index –assume-unchanged

My coworker has asked me if he could ingore a file after he had committed it, as an example a pom.xml file, commonly used in maven projects.

I found out the git update-index –assume-unchanged can be useful in this situation. But when I try to merge from another branch, git is still tracking the ignored file and a conflict happens.

What sould I do to avoid this? Should I use this command(git update-index assume-unchanged) in all the branches?

  • Git: Manage each version of my app?
  • How to manage Migrations in a project with multiple branches?
  • Converting a development team from FTP to a Versioning System
  • I have git repo with one branch: master. How do I rename the branch locally and on the remote repo?
  • What do you do if the file in TFS is locked by someone else?
  • Should I commit .rvmrc files in a project?
  • Mirroring a git subdirectory in a SVN subdirectory
  • What VCS alternatives to clearcase facilitate baseline functionality
  • 3 Solutions collect form web for “Problems with merging after a git update-index –assume-unchanged”

    The command git update-index --assume-unchanged filename can’t be used in two branches, it’s a way to temporarily ignore a file for a while. When you modify the file, and then want to switch or merge to other branches, git will show error message for you because you have un-commit changes, that means you should use git update-index --no-assume-unchanged filename before switch or merge branch.

    For your situation, you can refer below two ways:

    1. The file is no need to do version control any more. So you can add the file in .gitignore, and use git rm --cached filename to untrack it.
    2. Need to do version control for the file. When you merge branch, you can use git merge branchname -X ours/theirs to make the file has no effect.

    As I commented – --assume-unchanged isn’t the right tool for this job

    According to the Git documentation the best way of doing this is to use git rm --cached <file>;

    Another useful thing you may want to do is to keep the file in your working tree but remove it from your staging area. In other words, you may want to keep the file on your hard drive but not have Git track it anymore. This is particularly useful if you forgot to add something to your .gitignore file and accidentally staged it, like a large log file or a bunch of .a compiled files. To do this, use the --cached option

    You’d then need to add the now untracked file to your .gitignore file.

    For branches – you will have to manage the merging of your branches that do track this file to make sure it doesn’t make it’s way into the repository again. The easiest way would be to make this alteration in each branch prior to merging it.

    I found out the git update-index –assume-unchanged

    This tells git not to compare the file in the working directory with the current repository state.

    The merge on the other hand happens between to commits in the repository. therefore you still have conflicts if your merge with someone elses changes on the same file.

    Your example why you need that feature is mavens project configuration file.

    It feels to me that especially this file should not be ignored or otherwise excluded from the scm. So Why do you need that?

    My guess is that you have defined properties in your pom that point to local resources. If so: move that properties the settings.xml in "user.home"/.m2. This is where they belong.

    Git Baby is a git and github fan, let's start git clone.