问题
How can I ignore a specific file in LibGit2Sharp when I merge from one branch to another? For example,
- I have a database.xml metadata file in the main branch, lets call it branch (A);
- But then I diverge to branch (B).
- I then make changes and commit to the database.xml file in branch A, this results in branch (B) being out of date.
- However, I want to keep the database.xml file from branch B and not merge it with branch A. How is this done in LibGit2Sharp?
回答1:
Generally speaking, you want to:
- Begin a merge but do not commit the results. You want to perform the equivalent of
git merge --no-commit b
. - Check out the version of the file from the current branch (the version that you want to keep).
- Add that to the index.
- Commit the merge.
This will result in a merge that does not affect the file in question. Unfortunately, there is no capability to not commit the merge result in LibGit2Sharp yet. This will be added in pull request 643.
来源:https://stackoverflow.com/questions/22184968/how-can-i-ignore-a-specific-file-in-libgit2sharp-when-i-merge-from-one-branch-to