Skip to content
Prem Tiwari
  • WP Tutorials
  • Plugins
  • About Me
  • Featured On
  • Let’s Talk
Prem Tiwari

Remove directory from remote repository after adding them to .gitignore

ByEditorial Staff January 13, 2025

If you want to remove directory from remote repository after adding them to .gitignore? Use the following steps:

I’d do it with cherry-pick -n (–no-commit) which lets you inspect (and modify) the result before committing:

git cherry-pick -n 

# unstage modifications you don't want to keep, and remove the
# modifications from the work tree as well.
# this does work recursively!
git checkout HEAD 

# commit; the message will have been stored for you by cherry-pick
git commit

If the vast majority of modifications are things you don’t want, instead of checking out individual paths (the middle step), you could reset everything back, then add in what you want:

# unstage everything
git reset HEAD

# stage the modifications you do want
git add 

# make the work tree match the index
# (do this from the top level of the repo)
git checkout .

Related Questions

  • Maths full form | What is the full form of Maths?
  • What is the full form of WAP?
  • What is the full form of kiss?
  • PA Full Form | What is the full form of PA?
  • What is the full form of HFS?
  • How to update a GitHub forked repository?
  • KVIC full form | What is the full form of KVIC?
  • KCS Full Form | What is the full form of KCS ?
  • DDO Full Form | What is the full form of DDO?
  • How to disable sticky posts feature in WordPress

Collections

  • Crawling and indexing
  • Meetup
  • PHP
  • Plugins
  • SEO
  • Tech Talks
  • WooCommerce Tutorials
  • WordCamp
  • WordPress Tutorials
  • Privacy
  • Cookies
  • Disable Update Notifications
Facebook Twitter Instagram YouTube Linkedin WordPress
Scroll to top
  • WP Tutorials
  • Plugins
  • About Me
  • Featured On
  • Let’s Talk