1

How can I just merge the source code files, say *.h and *.cpp, in Git?

The repository on Github contains the whole solution file including project and compiler data and build executables.

danijar
  • 32,406
  • 45
  • 166
  • 297

1 Answers1

1

You can declare a merge driver in a .gitattributes file in order to:

Another option is described in this answer:

git merge --no-commit branchSource
# for each non .cpp or .h files:
git checkout branchDestination -- file

But that is a bit cumbersome.


That being said, a merge should involve the all content of a commit, which is why not* versioning elements you don't want to merge is a good idea.
When those elements can be generated at will (build executable), this is twice a good idea (as commented by KingCrunch).

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • `git checkout` will do a merge? That doesn't sound right. Won't `git checkout -- ` grab the versions of the file on ``? I didn't think it performed any merge operation here. – John Szakmeister Dec 29 '12 at 18:25
  • @jszakmeister true: I have fixed the answer to include a way to merge everything, and restore the destination branch version. – VonC Dec 29 '12 at 20:07