• Skip to primary navigation
  • Skip to main content
sharadchhetri

sharadchhetri

Tutorials On Linux, Unix & Open Source

  • Home
  • Linux Commands
  • Resources
    • Learn Linux
  • My WordPress plugins

How to remove file and directory from Git repo

December 29, 2013 by Sharad Chhetri Leave a Comment

In this post I am sharing the command to remove files and folder from git repo.The command will remove files from the working tree and from the index.
Note: Before removing any files and directory it is always a good practice to keep the backup of the data.Hence suggesting to first take the backup of your data.

Follow the given below steps to remove file and directory from git repo

We assume you have already cloned the repository in your system from git server.Here for eg. we are giving the repository name as test-repo

Step 1: Change to Working repository in your system

cd test-repo

Step 2: Here in this step, we will remove both file and directory

To remove the file from working tree and index,run the below command

git rm file-name

To remove directory,from working tree and index,run the below command

git rm -r dir-name

Note: If you want to remove all files and directory at a time,then change to directory and run below command. Here in below given command period(.) means from current location.

git rm -r .

Share this:

  • Twitter
  • Facebook
  • More
  • Print
  • Email
  • LinkedIn
  • Reddit
  • Tumblr
  • Pinterest
  • Pocket
  • Telegram
  • WhatsApp
  • Mastodon

Related posts:

  1. shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
  2. How to write description of git repo
  3. How to setup Jenkins Credentials for Git repo access
  4. NOTICE: nagios.cmd file not found. Please specify the location of this file in your /etc/vshell.conf file
  5. plugins/python/uwsgi_python.h:2:20: fatal error: Python.h: No such file or directory
  6. SCP file and directory in linux and Unix like operating system
  7. hash:/etc/postfix/virtual is unavailable. open database /etc/postfix/virtual.db: No such file or directory
  8. XAMPP : Mysql # 2002 – No such file or directory
  9. jemalloc/jemalloc.h: No such file or directory – Redis
  10. /usr/bin/env: node: No such file or directory

Filed Under: Git Server Tagged With: git

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Copyright © 2023 ยท
The material in this site cannot be republished either online or offline, without our permission.
Proudly Blogging From Bharat.

  • Contact
  • About Me
  • My WordPress plugins
  • Privacy Policy