Skip to content

Make Selenium Easy

And Keep It That Way

  • Home
  • Share
  • About Us
  • Toggle search form

Git Tutorial 26 – How To Ignore Already Indexed/staged/Committed/Pushed File to Git Repo

Posted on 04/23/2025 By admin

As a part of GIT Tutorials End To End, we will learn to ignore already Indexed/staged/Committed/Pushed File to Git Repo using the .gitignore file 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.

If you are now aware of the .gitignore file or how to create it then you must go through this post – Ignore Files Using the .gitignore

To learn basic patterns used in the .gitignore file refer to Important Pattern Formats For The .Gitignore File.

We create multiple files during the development of the project which are staged, committed and pushed to the remote repository. There might be scenarios in which you may need to remove some already staged and committed files and add them to the .gitignore file. If a file is not already staged or committed then we can simply add a pattern to ignore the file in the .gitignore file. But if the file is already indexed or committed then it is not a straightforward process.

Let’s create a local git repository with .gitignore to practice –

I will create a file and index/stage it first below-

As you can see above that I have staged or indexed filea.txt using git add command. Now I want GIT to ignore this file. If we add the pattern to ignore filea.txt in the .gitignore file now it will not work i.e. not ignored as the file was already indexed.

So to ignore the already staged file we need to go the extra step. First, we need to Unstage the file from the stage. To unstage a file we need to use the git rm command. Once we unstage the file, add the pattern to the .gitignore file to ignore it. I have already added the filea.txt in the .gitignore file above so I will just run the git rm command to unstage the file.

As you can see above filea.txt is no more shown as changes to be committed and is also ignored by git.

The same step needs to follow if the file is already pushed to the remote. After these steps, you need to add, commit and push to reflect changes.

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

Uncategorized

Post navigation

Previous Post: Understanding NullPointerException And How To Avoid It In Java/Selenium
Next Post: REST Assured Tutorial 16 – Building RequestSpecification Using RequestSpecBuilder

Related Posts

How To Sort List In Ascending & Descending Order Using Java Stream API? Uncategorized
Postman Tutorial Part 20 – Use Variables in Request Builder OR How To Build Parameterized Request in Postman Uncategorized
naviagte – Make Selenium Easy Uncategorized
cropped-cssInConsole.png Uncategorized
rest assured Uncategorized
REST Assured Tutorial 31 – How To Create POJO Classes Of A Nested JSON Payload Uncategorized

Recent Posts

  • How to Set Up Selenium WebDriver with Python Step by Step
  • How to Set Up Selenium WebDriver with Java from Scratch
  • What Is Selenium and Why It Is the Most Popular Test Automation Framework
  • Getting Started with Selenium 4: What Is New and How to Upgrade from Selenium 3
  • Manual Testing

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