How can I ignore a specific file in LibGit2Sharp when I merge from one branch to another?

How can I ignore a specific file in LibGit2Sharp when I merge from one branch to another? For instance,

  • I have a database.xml metadata file in the main branch, which allows me to call it branch (A);
  • But then I deviate to branch (B).
  • Then I make changes and commit the database.xml file to branches A, this leads to obsolescence of branch (B).
  • However, I want to save the database.xml file from branch B and not merge it with branch A. How is this done in LibGit2Sharp?
+1
source share
1 answer

Generally speaking, you want:

  • Start the merger, but don’t commit the results. You want to execute the equivalent of git merge --no-commit b .
  • Check the version of the file from the current branch (the version you want to keep).
  • Add this to the index.
  • Complete the merge.

This will result in a merge that does not affect the file. Unfortunately, there is no way in LibGit2Sharp not to transfer the result of the merge. This will be added to the 643 retrieval request .

+2
source

All Articles