Git: Stop Tracking File After Adding to .gitignore

Git: Stop Tracking File After Adding to .gitignore

.gitignore will prevent untracked files from being added (without an add -f ) to the set of files tracked by git. In this tutorial, we'll take a look at how to stop tracking a file after adding it to .gitignore post-festum, with and without removing it from the repository. Git: Stop Tracking File After Adding to .gitignore

Accidentally forgot to add a file to the .gitignore file and started tracking it with other files? Or perhaps a remote repository already has a file tracked that you've cloned, but would like to stop tracking?

Just as important as tracking changes is not tracking them in certain cases, lest they change the scale of what you're keeping an eye on. Once a fille is tracked, even if you add it to _`.gitignore_`, it will still be tracked.

In this tutorial, we'll take a look at two ways on how to stop tracking a file on Git, after adding it to _`.gitignore_`.

Choosing between these two depends on whether you want the file to be kept in the repository or not.

Stop Tracking File and Remove It From the Repository

First, let's go ahead and create a couple of files, add them to the index and commit themm to the repository:

$ touch file.txt
$ touch file2.txt
$ git add .
$ git commit -m "Initial commit"

git

What is Geek Coin

What is GeekCash, Geek Token

Best Visual Studio Code Themes of 2021

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Best Practices for Using Git

Git has become ubiquitous as the preferred version control system (VCS) used by developers. Using Git adds immense value especially for engineering teams where several developers work together since it becomes critical to have a system of integrating everyone's code reliably.

7 Best Practices in GIT for Your Code Quality

Git plays a significant role in software development. It allows developers to work on the same code base at the same time. Check out 7 best practices for Git.There is no doubt that Git plays a significant role in software development. It allows developers to work on the same code base at the same time. Still, developers struggle for code quality.

Git Commands You Can Use To Dig Through Your Git History

Git Commands You Can Use To Dig Through Your Git History. In this short article, we’ll be exploring some quick git commands that can help us in digging through our repositories’ history of commits.

Git Rebase Tutorial and Comparison with Git Merge

In this article, I will explain to you a few differences between git merge, git rebase, and the git interactive rebase.I will tell a bit about what pros...

Mirroring Git Changes From One Server to Another Server

Hello all, nowadays most of the development teams using GIT version control, some of you may have a requirement of mirroring your team's git changes from one server to another Git server. This article will help you to achieve the Git mirroring between one server to another server.