* can I always ignore a file during a merge? @ 2012-06-27 23:39 Stephen Bannasch 2012-07-03 7:38 ` Jeff King 0 siblings, 1 reply; 3+ messages in thread From: Stephen Bannasch @ 2012-06-27 23:39 UTC (permalink / raw) To: git Is there a way to merge from branchA to branchB and from branchB to branchA while completely ignoring changes to a file that is tracked and exists in both branches? ---- details ---- I have two branches in my project (master and energy2d) automatically being built and tested on travis-ci: http://travis-ci.org/#!/concord-consortium/lab When failures in tests occur notifications are sent to emails in a configuration file checked into each branch: master: https://github.com/concord-consortium/lab/blob/master/.travis.yml energy2d: https://github.com/concord-consortium/lab/blob/energy2d/.travis.yml I regularly merge work in the energy2d branch into master and the Google Summero of Code student I am working with regularly merges changes in master into energy2d. I would like to be able to merge both directions while completely ignoring changes in the travis-ci configuration files in each branch. I have tried creating a .gitattributes file in each branch with the following content: .travis.yml merge=ours But when interpreted by the default merge strategy "recursive" this only applies when there are conflicts -- however this current difference is not seen as a conflict: $ git diff energy2d .travis.yml diff --git a/.travis.yml b/.travis.yml index 8ea58dc..ec89f91 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,8 @@ notifications: email: recipients: - stephen.bannasch@gmail.com - - janikpiotrek@gmail.com + - sfentress@concord.org + - rpk@pobox.com language: node_js node_js: - 0.6 Which means every time we merge the .travis.yml file is updated on the branch we are merging to. ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: can I always ignore a file during a merge? 2012-06-27 23:39 can I always ignore a file during a merge? Stephen Bannasch @ 2012-07-03 7:38 ` Jeff King 2012-07-05 19:49 ` Philip Oakley 0 siblings, 1 reply; 3+ messages in thread From: Jeff King @ 2012-07-03 7:38 UTC (permalink / raw) To: Stephen Bannasch; +Cc: git On Wed, Jun 27, 2012 at 07:39:03PM -0400, Stephen Bannasch wrote: > Is there a way to merge from branchA to branchB and from branchB to > branchA while completely ignoring changes to a file that is tracked > and exists in both branches? No. Fundamentally, a commit object in git consists of a content state (i.e., a pointer to a tree object) and a pointer to all previous history (i.e., zero or more "parent" pointers to commit objects). The semantics of a commit object can be thought of as "I have looked at all of the history in all of the parent commits, and the state contained in my tree pointer supersedes them all". So you could make merge B into A, but keep A's copy of the file (e.g., using the "ours" strategy). But that is saying that you considered the state of both A and B, and decided that A's version supersedes what happened in B. If you later wanted to merge from A to B, B's version of the file would not even be considered as an outcome for the merge. There isn't really a clever way to work around this via a different merge strategy; it's a fundamental aspect of git's data structure for storing history. -Peff ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: can I always ignore a file during a merge? 2012-07-03 7:38 ` Jeff King @ 2012-07-05 19:49 ` Philip Oakley 0 siblings, 0 replies; 3+ messages in thread From: Philip Oakley @ 2012-07-05 19:49 UTC (permalink / raw) To: Stephen Bannasch; +Cc: git, Jeff King From: "Jeff King" <peff@peff.net> To: "Stephen Bannasch" <stephen.bannasch@deanbrook.org> Sent: Tuesday, July 03, 2012 8:38 AM Subject: Re: can I always ignore a file during a merge? > On Wed, Jun 27, 2012 at 07:39:03PM -0400, Stephen Bannasch wrote: > >> Is there a way to merge from branchA to branchB and from branchB to >> branchA while completely ignoring changes to a file that is tracked >> and exists in both branches? > > No. Fundamentally, a commit object in git consists of a content state > (i.e., a pointer to a tree object) and a pointer to all previous > history > (i.e., zero or more "parent" pointers to commit objects). The > semantics > of a commit object can be thought of as "I have looked at all of the > history in all of the parent commits, and the state contained in my > tree > pointer supersedes them all". > > So you could make merge B into A, but keep A's copy of the file (e.g., > using the "ours" strategy). But that is saying that you considered the > state of both A and B, and decided that A's version supersedes what > happened in B. If you later wanted to merge from A to B, B's version > of > the file would not even be considered as an outcome for the merge. > > There isn't really a clever way to work around this via a different > merge strategy; it's a fundamental aspect of git's data structure for > storing history. Stephen, One thought, following too much reading of the manual, is to use the merge --squash option, which leaves you with the index ready for a commit, and then revert the undesired file using checkout -- <file>, followed with git add <file>, and if you want both merge parents set the MERGE_HEAD as required (see the man pages) before the final commit. Philip > > -Peff > -- ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-07-05 19:49 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-06-27 23:39 can I always ignore a file during a merge? Stephen Bannasch 2012-07-03 7:38 ` Jeff King 2012-07-05 19:49 ` Philip Oakley
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).