# Exclude a directory while merging

2 messages from 2009-07-30 to 2009-07-30. Participants: Vlad Didenko, Dmitry Potapov.
Thread: https://gitlist.dev/t/20296

## Vlad Didenko, 2009-07-30 12:12

Subject: Exclude a directory while merging
Message-ID: <C696F858.CEB0%vdidenko@Getcollc.com>
URL: https://gitlist.dev/e/C696F858.CEB0%25vdidenko%40Getcollc.com

```
Colleagues,

Is there an easy way to exclude a directory from a merge operation.
Specifically:

We have a "master" branch. We also have an "other" branch. There is a
directory XYZ in the other branch which is not in the master. I need to
merge everything but XYZ into master. Something like that:

git checkout master
git merge other --exclude XYZ

Is that possible?

Thank you!
Vlad


This e-mail and its attachments are intended only for the individual or entity to whom it is addressed and may contain information that is confidential, privileged, inside information, or subject to other restrictions on use or disclosure. Any unauthorized use, dissemination or copying of this transmission or the information in it is prohibited and may be unlawful. If you have received this transmission in error, please notify the sender immediately by return e-mail, and permanently delete or destroy this e-mail, any attachments, and all copies (digital or paper). Unless expressly stated in this e-mail, nothing in this message should be construed as a digital or electronic signature.

```

## Dmitry Potapov, 2009-07-30 12:42

Subject: Re: Exclude a directory while merging
Message-ID: <20090730124224.GC27178@dpotapov.dyndns.org>
URL: https://gitlist.dev/e/20090730124224.GC27178%40dpotapov.dyndns.org
In-Reply-To: <C696F858.CEB0%vdidenko@Getcollc.com>

```
Hi,

On Thu, Jul 30, 2009 at 07:12:24AM -0500, Vlad Didenko wrote:
> 
> Is there an easy way to exclude a directory from a merge operation.

You cannot merge some directories but not other, but you always can
discard any changes during merge.

> Specifically:
> 
> We have a "master" branch. We also have an "other" branch. There is a
> directory XYZ in the other branch which is not in the master. I need to
> merge everything but XYZ into master. Something like that:
> 
> git checkout master
> git merge other --exclude XYZ

I have not tried, but it should be like this:

git merge --no-commit other
git checkout HEAD XYZ  # or 'git rm XYZ' if XYZ does not exist on master
git commit

NOTE: Git will consider all changes including the directory XYZ as
already merged into master and will not try to merge it later (unless
there are some other changes to that directory).

Dmitry

```
