We're using posh-git on Windows Powershell for source control.
We're in the unenviable position of storing some of our built assemblies in our git repo. I know all the sermons on why you shouldn't do that, but we have to live with it for now. Thankfully they are in a separate solution, but sometimes two people work on that solution in their own branch simultaneously, and the last one in gets to take the merge conflict. The process, of course, looks something like this:
- Person A lands their changes on develop.
- Person B merges those changes, which include both assemblies and update source code.
- Person B resolves conflicts, as has to confirm which version of each assembly they want to keep. This is annoying and time-consuming, and also unnecessary since Person B will rebuild the assembly after merging the source code anyway.
- Person B rebuilds the assemblies and makes a new commit to finish the merge.
The assemblies are in a folder in our Repo: /Source/Foundation Assemblies/
Person B cannot just take all changes from the remote, since their branch may have conflicting changes, but it would be helpful to just "take theirs" or "take mine" for the /Source/Foundation Assemblies/ folder only. Is this something that can be done with git?
A command line example would be helpful. Normally, the merge would just be:
git merge develop
I was thinking it might be possible to .gitignore the /Source/Foundation Assemblies/ folder, and then remove it from the .gitignore after the merge, but that is three steps. If we could do it in one from the command line, that would be GREAT!!!
Any help appreciated!
You can do
git merge develop -X theirs
, and all conflicts will take the remote branch's copies.Edit: Looking back over your question I see that you only want to take "theirs" for a particular subfolder. In that case, after
git merge develop
, dogit checkout --theirs /Source/Foundation Assemblies/
. This will replace the contents of that folder with "theirs". Then justgit add /Source/Foundation Assemblies/
and you are good to go.You have several merge strategies which you can use:
resolve
recursive
ours
theirs
and even more but those are the main ones.
The "right" way in your case is to rebuild the assemblies before committing the merge. I don't see why you would not do this. The steps as follows should work:
git add
all conflicted sources. Then whatever happens during merge should not affect what you commit.git add
the ready assemblies.EDIT: try this:
git rm --force -r <dirname>
kdiff3
did not)git add <dirname>
I tried this bash script to reproduce you case as I understand it.