dugla
dugla

Reputation: 12954

Github. How do I make changes to what is ignored via .gitignore?

I have an Xcode project that uses git for version control. I have a .gitignore file to ignore the build subdirectory:

build/*

I recently added a subdirectory that contains an Xcode project and forgot to update the .gitignore file before checking it in.

Is there any way to make git ignore the build subdirctory now, after the fact?

Thanks, Doug

Upvotes: 1

Views: 221

Answers (1)

VonC
VonC

Reputation: 1324937

 git rm --cached dirToignore
 echo dirToignore >>.gitignore

From there, a new commit will record that:

  • dirToignore is no longer par of versioned data
  • dirToIgnore won't show up anymore in git status

See this SO question for similar advices.
If you want to amend previous commit in order to remove said subdirectory from an old commit, see this SO question:

 git commit --amend

can help you remove it from at least the last commit.

Upvotes: 4

Related Questions