1

I git cloned an arduino sketch that requires me to remove the libraries directory and place it elsewhere outside the repo via mv ./libraries $sketchdir/sketch_libraries/. I can't compile the sketch with the directory present so I deleted it; however, when I run git status it complains about the missing contents of the libraries directory.

I'd like to tell git to ignore the fact that this directory is missing on purpose and stop pestering me. I tried adding libraries/* to .gitignore, but that failed to give me the desired results.

How can I accomplish this?

Josiah
  • 2,666
  • 5
  • 30
  • 40
  • 1
    Please edit your question to show the commands you ran and what didn't work as you wanted. Without the details we can only guess at what the issue is. – msw Jan 28 '16 at 07:19

2 Answers2

2

If you want to ignore that directory only on a specific host, try adding the directory path to the .git/info/exclude instead of .gitignore:

Your exclude file should look like this:

# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
libraries/*

git status won't even complain that the exclude file has changed.

Loukan ElKadi
  • 2,687
  • 1
  • 16
  • 20
  • I added libraries/* to the `.git/info/exclude` file and ran `git status`, but it still includes all my deleted files in libraries/*. Did I miss something? – Josiah Jan 29 '16 at 04:09
  • Would you please copy the message returned by `git status`, and paste it here? – Loukan ElKadi Jan 29 '16 at 06:52
  • There is a lot, but I think the top should give you what you are looking for: On branch master Your branch is up-to-date with 'origin/master'. Changes not staged for commit: (use "git add/rm ..." to update what will be committed) (use "git checkout -- ..." to discard changes in working directory) modified: keyer_features_and_options.h deleted: libraries/Adafruit_MCP23017.cpp deleted: libraries/Adafruit_MCP23017.h deleted: libraries/Adafruit_RGBLCDShield.cpp Sorry about the ugly formatting. – Josiah Jan 29 '16 at 15:58
  • Check my new answer below . – Loukan ElKadi Jan 29 '16 at 20:21
0

I just figured out what's the issue here. By adding the directory to the .gitignore or the info/exclude, git wont track that directory if it's local. But in this case, you want to remove it locally and keep it on the remote repo, and want git to untrack that remote directory.

To do so, you just run this command:

git update-index --skip-worktree libraries/*

Loukan ElKadi
  • 2,687
  • 1
  • 16
  • 20