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
  • 30,040
  • 39
  • 151
  • 272

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,129,465
  • 480
  • 4,036
  • 4,755
  • `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