質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Git

Gitはオープンソースの分散バージョン管理システム(DVCS)です。

Q&A

解決済

1回答

2092閲覧

git merge --allow-unrelated-histories 時に、あるディレクトリ以下を merge 対象外にするには

roswell

総合スコア17

Git

Gitはオープンソースの分散バージョン管理システム(DVCS)です。

0グッド

0クリップ

投稿2019/01/23 05:05

Git merge時に、.local 以下を merge 対象外にするために、

yama@jpx20120007:/tmp/yama$ cat .gitattributes /.local/* merge=ours yama@jpx20120007:/tmp/yama$ cat .git/config [core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true [remote "origin"] url = yama@XXX.XXX.XXX.XXX:/git_repository/home.git fetch = +refs/heads/*:refs/remotes/origin/* [branch "master"] pushRemote = origin remote = origin merge = refs/heads/master [merge "ours"] name = "Keep ours merge" driver = true

とし、git merge すると

yama@jpx20120007:/tmp/yama$ git merge -v fatal: refusing to merge unrelated histories

となって、merge が失敗するので、
--allow-unrelated-histories オプションをつけて、merge 実行すると

yama@jpx20120007:/tmp/yama$ git merge -v --allow-unrelated-histories ... Auto-merging .local/share/fish/generated_completions/zdump.fish CONFLICT (add/add): Merge conflict in .local/share/fish/generated_completions/zdump.fish Auto-merging .local/share/fish/generated_completions/x509.fish CONFLICT (add/add): Merge conflict in .local/share/fish/generated_completions/x509.fish Auto-merging .local/share/fish/generated_completions/wipefs.fish CONFLICT (add/add): Merge conflict in .local/share/fish/generated_completions/wipefs.fish Auto-merging .local/share/fish/generated_completions/who.fish ... Automatic merge failed; fix conflicts and then commit the result.

となって、
.local以下のファイルが、merge されてしまいます。
.local以下をmerge時の対象外にするにはどのようにすればよいかご教示お願いします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

https://git-scm.com/docs/gitignore)https://git-scm.com/docs/gitignore
中に、

A trailing /** matches everything inside.
For example, "abc/**" matches all files inside directory "abc"

とあり、

yama@jpx20120007:/tmp/yama$ cat .gitattributes /.local/* merge=ours

yama@jpx20120007 /t/yama> cat .gitattributes /.local/** merge=ours

と、'**' とすることで解決しました。

投稿2019/01/23 08:49

roswell

総合スコア17

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問