Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does git ignore files that have been submitted

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the relevant knowledge of "how git ignores documents that have been submitted". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Git ignores files that have been submitted

Some files have been submitted, but we want to ignore the tracking of these files while we are working on the project later. These files still want to be kept on the local disk

At this point, we can do this:

Gitrm--cachesomefiles deletes the local cache

Update the gitignore file and ignore the target file (somefiles)

Finally, gitcommit-m'Wedon'tneedthatsomefiles

Note that under this method, somefiles will only be retained on the submitter's disk, and if other developers pull your commit, these files on their disk will also disappear, but the filtered IDEA files, and after other developers pull down the code, they use IDEA to refresh the maven project, and those missing files will be regenerated, and everyone has their own local files, iml,idea and other files that do not need to be tracked.

If you want to delete all files in the directory, including the gitrm-r--cached in the subdirectory

Git ignores how files that have been submitted resume tracking

Problem description

Previously, when submitting the code, the .gitignore was not completed, resulting in the idea editor's configuration folder .idea being submitted.

Then every time you run a local project, you will generate a pile of files under the .idea folder. When you find a problem, fill in the .idea / in the .gitignore rule, but when you run gitstatus, you can still see these files.

Solution.

The right thing to do is to gitrm--cached.idea-r, then update. Gitignore ignores the target file, and finally gitcommit-m "Wereallydon'twantGittotrackthisanymore!"

By this time, the problem has been solved.

But the question is: why did I add the rules in gitignore but didn't work?

This is because .gitignore files can only work on UntrackedFiles, that is, files that have never been recorded by Git (files that have never been add or commit since they were added).

All the files under my .idea have been recorded by git, so .resume is not valid for them at all. Delete the tracking of the folder from the Git database, update the .gitignore, and then submit it.

How do you restore tracking of a file / folder?

Just delete the rules for this file / folder from .gitignore

This is the end of the content of "how git ignores files that have been submitted". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report