Skip to content

Make Selenium Easy

And Keep It That Way

  • Home
  • Share
  • Toggle search form

Git Tutorial 12 – Git Rm – Remove Files From Working And Staging (Index) Directory

Posted on 02/19/2025 By admin

As a part of GIT Tutorials End To End, we will learn about another frequently used and important git command “git rm“ in this post.

I will expect that you are aware of the basic concepts and commands of GIT. But if you are a beginner in GIT then I strongly recommend you to refer GIT Basic Commands and Concepts section on my blog first.

Did you know that I have started a YouTube channel as well and I need your support to make it successful. Please do watch content then comment, like, share, and obviously subscribe.

“Rm” stands for remove and this command is used to remove/delete files from your working directory and staging or git repository. Let’s learn about this command with examples

I have initiated a git directory and added a file as below:-

I have not added a new file “FileA” into staging/index using “git add” command yet. If we want to remove this file then we are NOT supposed to use “git rm” command as the file is yet to be tracked by git. If we try to remove this file using “git rm” command we will get an error as below.

To remove files not tracked by git, we can use “rm ” command as shown below:-

Let’s create a new file again and add it to the staging area and try to delete the file using “git rm ” command. You will get an error as below:-

The reason behind this is that we have already staged/indexed FileA and have not committed yet. So here we have two options. Either use the “-f” option to forcefully remove the file from the index and working directory or use the “–cached” option to remove the file from the index/staging area but keep it local. In the second option, you will reach the state before the git add command. If you have committed the file then you will be able to remove the file easily.

You can remove a committed file easily but need to recommit and push to make changes in a git repository.

To remove the directory we need to use -r option with the command.

git rm -r

Please subscribe to my YouTube channel Retarget Common to learn from my video tutorials.

Below are important end to end tutorials for Testers:-

Selenium Tutorials

Rest Assured Tutorials

Postman Tutorials

TestNG Tutorials

If you have any doubt, feel free to comment below.If you like my posts, please like, comment, share and subscribe.#ThanksForReading

#HappyLearning

Uncategorized

Post navigation

Previous Post: Interview Experience at Capgemini Bangalore for Selenium Java Profile ( Aug – 2019)
Next Post: Must Read

Related Posts

Hierarchy of Selenium Classes and Interfaces – Make Selenium Easy Uncategorized
TestNG Tutorials 39: Run Only Test From a TestNG Class Without Using TestNG XML? Uncategorized
MSE-ReadyToUseSeleniumCode – Storing Web Table Data Into List Of Map – Java Uncategorized
GIT Tutorials – End To End Archives – Page 3 of 3 – Make Selenium Easy Uncategorized
REST Assured Tutorial 60 – Learn to write JsonPath expressions or JsonPath syntax Uncategorized
Protractor Tutorial 3 – Prerequisites To Learn Protractor Uncategorized

Recent Posts

  • Getting Started with Selenium 4: What Is New and How to Upgrade from Selenium 3
  • Manual Testing
  • Baby Steps To Become Efficient Selenium-Java Automation Tester
  • Features of Selenium 4.0.0 Release – Java Binding
  • Part 1: Handling Drop-down Created Using SELECT Tag In Selenium

Recent Comments

No comments to show.

Archives

  • April 2026
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • April 2024
  • March 2024
  • February 2024
  • December 2023
  • October 2023
  • August 2023
  • November 2022
  • September 2022
  • August 2022
  • July 2022
  • May 2022
  • March 2022
  • October 2021
  • April 2021
  • March 2021
  • January 2021
  • December 2020
  • October 2020
  • September 2020
  • August 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • May 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • January 2018

Categories

  • Getting Started
  • Uncategorized

Copyright © 2026 Make Selenium Easy.

Powered by PressBook Masonry Dark