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

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

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

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

GitHub

GitHubは、Gitバージョン管理システムを利用したソフトウェア開発向けの共有ウェブサービスです。GitHub商用プランおよびオープンソースプロジェクト向けの無料アカウントを提供しています。

Q&A

解決済

1回答

516閲覧

gitである特定のフォルダのみトラックする

nouken

総合スコア369

Git

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

GitHub

GitHubは、Gitバージョン管理システムを利用したソフトウェア開発向けの共有ウェブサービスです。GitHub商用プランおよびオープンソースプロジェクト向けの無料アカウントを提供しています。

0グッド

2クリップ

投稿2019/05/08 16:37

. ├── README.md └── book-js ├── 2-01_console │   └── step1 │   └── index.html ├── 2-02_tag │   ├── step1 │   │   └── index.html │   └── step2 │   ├── index.html │   └── script.js ├── 2-03_alert │   └── step1 │   └── index.html ├── 2-04_html │   ├── extra │   │   └── index.html │   ├── step1 │   │   └── index.html │   └── step2 │   └── index.html ├── 3-01_if │   ├── step1 │   │   └── index.html │   └── step2 │   └── index.html ├── 3-02_var │   ├── step1 │   │   └── index.html │   └── step2 │   └── index.html ├── 3-03_elseif │   └── step1 │   └── index.html ├── 3-04_comparison │   └── step1 │   └── index.html ├── 3-05_logical │   └── step1 │   └── index.html ├── 3-06_for │   ├── step1 │   │   └── index.html │   └── step2 │   └── index.html ├── 3-07_while │   ├── step1 │   │   └── index.html │   └── step2 │   └── index.html ├── 3-08_function │   ├── extra │   │   └── index.html │   ├── step1 │   │   └── index.html │   └── step2 │   └── index.html ├── 3-09_fizzbuzz │   ├── step1 │   │   └── index.html │   └── step2 │   └── index.html ├── 3-10_array │   ├── step1 │   │   └── index.html │   ├── step2 │   │   └── index.html │   ├── step3 │   │   └── index.html │   └── step4 │   └── index.html ├── 3-11_object │   ├── step1 │   │   └── index.html │   ├── step2 │   │   └── index.html │   └── step3 │   └── index.html ├── 4-01_input │   ├── step1 │   │   └── index.html │   └── step2 │   └── index.html ├── 4-02_12hour │   ├── step1 │   │   └── index.html │   └── step2 │   └── index.html ├── 4-03_digit │   ├── step1 │   │   └── index.html │   └── step2 │   └── index.html ├── 4-04_math │   └── step1 │   └── index.html ├── 5-01_countdown │   ├── step1 │   │   └── index.html │   ├── step2 │   │   └── index.html │   └── step3 │   └── index.html ├── 5-02_location │   ├── step1 │   │   ├── index-en.html │   │   ├── index-zh.html │   │   ├── index.html │   │   └── script.js │   └── step2 │   ├── index-en.html │   ├── index-zh.html │   ├── index.html │   └── script.js ├── 5-03_cookie │   └── step1 │   ├── index.html │   └── thankyou.html ├── 5-04_image │   ├── step1 │   │   ├── img1.jpg │   │   ├── img2.jpg │   │   ├── img3.jpg │   │   ├── index.html │   │   ├── thumb-img1.jpg │   │   ├── thumb-img2.jpg │   │   └── thumb-img3.jpg │   └── step2 │   ├── img1.jpg │   ├── img2.jpg │   ├── img3.jpg │   ├── index.html │   ├── thumb-img1.jpg │   ├── thumb-img2.jpg │   └── thumb-img3.jpg ├── 5-05_slide │   ├── extra │   │   ├── images │   │   │   ├── image1.jpg │   │   │   ├── image2.jpg │   │   │   ├── image3.jpg │   │   │   ├── image4.jpg │   │   │   ├── image5.jpg │   │   │   ├── next.png │   │   │   └── prev.png │   │   └── index.html │   ├── step1 │   │   ├── images │   │   │   ├── image1.jpg │   │   │   ├── image2.jpg │   │   │   ├── image3.jpg │   │   │   ├── image4.jpg │   │   │   ├── image5.jpg │   │   │   ├── next.png │   │   │   └── prev.png │   │   └── index.html │   └── step2 │   ├── images │   │   ├── image1.jpg │   │   ├── image2.jpg │   │   ├── image3.jpg │   │   ├── image4.jpg │   │   ├── image5.jpg │   │   ├── next.png │   │   └── prev.png │   └── index.html ├── 6-01_menu │   └── step1 │   └── index.html ├── 6-02_box │   ├── extra │   │   └── index.html │   └── step1 │   └── index.html ├── 6-03_ajax │   └── step1 │   ├── data.json │   └── index.html ├── 7-01_rss │   ├── basicfeed.xml │   ├── extra │   │   ├── index.html │   │   └── samplefeed.xml │   ├── step1 │   │   ├── cdxml.php │   │   └── index.html │   ├── step2 │   │   ├── cdxml.php │   │   └── index.html │   └── step3 │   ├── cdxml.php │   └── index.html ├── 7-02_photo │   ├── extra │   │   ├── index.html │   │   ├── loading.gif │   │   └── script.js │   ├── step2 │   │   ├── index.html │   │   ├── loading.gif │   │   └── script.js │   ├── step3 │   │   ├── index.html │   │   ├── loading.gif │   │   └── script.js │   └── step4 │   ├── index.html │   ├── loading.gif │   └── script.js ├── _common │   ├── css │   │   └── style.css │   ├── images │   │   ├── body-bg.png │   │   ├── header-bg.png │   │   └── header-logo.png │   └── scripts │   ├── js-cookie │   │   ├── CONTRIBUTING.md │   │   ├── Gruntfile.js │   │   ├── MIT-LICENSE.txt │   │   ├── README.md │   │   ├── bower.json │   │   ├── package.json │   │   ├── src │   │   │   └── js.cookie.js │   │   ├── test │   │   │   ├── amd-config.js │   │   │   ├── amd.html │   │   │   ├── amd.js │   │   │   ├── commonjs.js │   │   │   ├── encoding.html │   │   │   ├── encoding.js │   │   │   ├── index.html │   │   │   ├── malformed_cookie.html │   │   │   ├── polyfill.js │   │   │   ├── tests.js │   │   │   └── utils.js │   │   └── travis.sh │   └── js.cookie.js └── practice ├── 2-02_tag │   └── script.js ├── 2-04_html │   └── index.html ├── 3-02_var │   └── index.html ├── 3_01_if │   └── index.html └── _template └── index.html

のようなフォルダがあって /book-js/practice/フォルダに含まれるファイルのみトラックしたいです。

ググると.gitginoreを以下のようにすれば良いとわかったのですが、

#practiceのみ追跡する /* !/.gitignore !/book-js/practice/

/book-js/practice/下に新たなファイルを作ってgit statusしても

On branch master Your branch is up to date with 'origin/master'. nothing to commit, working tree clean

となるのでトラックされていないようです。
試しに、.gitignoreを全て消しgit statusすると全ファイルがトラックされてるのが確認できるので、どうも.gitignoreの書き方が悪いのかなと思いますが、いくつか他のパターンを試してもうまくいきません。

何が間違っているのかご教授ください。よろしくお願いします。

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

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

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

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

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

guest

回答1

0

ベストアンサー

検索してみたところ、ワイルドカードで上位のディレクトリがトラック対象から外れると、その中のディレクトリやファイルをあとから除外してトラック対象にすることはできないようです。

参考URL:
https://qiita.com/anqooqie/items/110957797b3d5280c44f

以下のようにされてはいかがでしょうか。

/* !/book-js/ /book-js/* !/book-js/practice/

投稿2019/05/08 19:34

tjmsy

総合スコア55

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

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

nouken

2019/05/09 12:53

無事解決しました。非常に有用な記事のご紹介ありがとうございました!
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問