git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Philip Oakley" <philipoakley@iee.org>
To: "Git List" <git@vger.kernel.org>
Subject: mergetool: what to do about deleting precious files?
Date: Sat, 27 May 2017 11:03:09 +0100	[thread overview]
Message-ID: <8CEDDC40C7D24404976929CF3E7AF6FC@PhilipOakley> (raw)

The git book [1] and a few blog posts [2] show how to preserve files which
are in the current branch against changes that are on the branch being
merged in.

e.g. (from [2])

echo '<filemane> merge=ours' >> .gitattributes && # commit
git config --global merge.ours.driver true

(test) $ git checkout demo
(demo) $ git merge -
# <filename> contents are not merged and the original retained.



However what is not covered (at least in the documentation ) is the case
where the file to be ignored is not present on the current branch, but is
present on the branch to be merged in.

Normal expectations would be that in such a case the new file from the
second parent branch would be added to the current branch.

Is there an easy way to use the current mergedriver mechanism to make this
new file from the second parent 'go away' - does one have to delete output
path (%P) or what? (or is this just a documenation issue?) [3]


Inspired by SO Q&A
https://stackoverflow.com/questions/44131926/git-merge-remove-unnecessary-file-folder/44138354#44138354
"
git merge
I'm trying to merge my dev branch to master, but I don't want to merge some
of the files/folders to master branch, because it is not needed now on
Master."


Any suggestions for a simple merge driver to avoid merging and commiting
such precious files from the second parent at merge time?
--
Philip

[1]
http://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes#Merge-Strategies
[2]
https://medium.com/@porteneuve/how-to-make-git-preserve-specific-files-while-merging-18c92343826b
[3]
https://git-scm.com/docs/gitattributes #Defining a custom merge driver:
"The merge driver can learn the pathname in which the merged result will be
stored via placeholder %P."


             reply	other threads:[~2017-05-27 10:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-27 10:03 Philip Oakley [this message]
2017-05-28  1:14 ` mergetool: what to do about deleting precious files? Junio C Hamano
2017-05-28 10:24   ` Philip Oakley
2017-05-28 13:06     ` Junio C Hamano
2017-05-29 12:57       ` Philip Oakley
2017-05-30  0:52         ` Junio C Hamano
2017-05-30 23:04           ` Philip Oakley
2017-05-31  0:02             ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8CEDDC40C7D24404976929CF3E7AF6FC@PhilipOakley \
    --to=philipoakley@iee.org \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).